From 5d62f313d5681388461631fa81d11e16b3affda2 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Tue, 16 Aug 2016 01:22:41 +0200 Subject: [PATCH] added mac screen region check --- Testing.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ switcher.cpp | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 Testing.cpp diff --git a/Testing.cpp b/Testing.cpp new file mode 100644 index 00000000..c711b929 --- /dev/null +++ b/Testing.cpp @@ -0,0 +1,66 @@ +/* + * SceneSwitcher.cpp + * SceneSwitcher + * + * Created by Till Wickenheiser on 25.06.16. + * Copyright © 2016 WarmUpTill. All rights reserved. + * + */ +#include +#include "SceneSwitcher.hpp" +#ifdef __APPLE__ //&& __MACH__ +//do stuff for mac +#endif +#ifdef __WINDOWS__ +//do stuff for windows +//this is so cool ! :D +string GetActiveWindowTitle() +{ + char wnd_title[256]; + //get handle of currently active window + HWND hwnd = GetForegroundWindow(); + GetWindowTextA(hwnd, wnd_title, sizeof(wnd_title)); + return wnd_title; +} +#endif + + +void HelloWorldPriv(const char * s) +{ + std::string cmd = "osascript -e 'tell application \"System Events\"' -e 'set frontApp to name of first application process whose frontmost is true' -e 'end tell'"; + system(cmd.c_str()); + std::cout << s << std::endl; +}; + + +//OSErr err; +//CGSValue titleValue; +//char *title; +//CGSConnection connection = _CGSDefaultConnection(); +//int windowCount, *windows, i; +// +//NSCountWindows(&windowCount); +//windows = malloc(windowCount * sizeof(*windows)); +//if (windows) { +// NSWindowList(windowCount, windows); +// for (i=0; i < windowCount; ++i) { +// err = CGSGetWindowProperty(connection, windows[i], +// CGSCreateCStringNoCopy("kCGSWindowTitle"), +// &titleValue); +// title = CGSCStringValue(titleValue); +// } +// free(windows); +//} +// +//Int getActiveWindowOSX(){ +// NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init]; +// NSApplication *myApp; +// +// +// myApp=[NSApplication sharedApplication]; +// +// NSWindow *myWindow = [myApp keyWindow]; +// +// [pool release]; +// return NWSindow; +//}; diff --git a/switcher.cpp b/switcher.cpp index 1b9846a8..12f3ac35 100644 --- a/switcher.cpp +++ b/switcher.cpp @@ -12,7 +12,7 @@ #endif #ifdef __APPLE__ #include -#include +#include #endif using namespace std;