问题
How to get Window reference (CGWindow, NSWindow or WindowRef) from CGWindowID in Swift on XCode 7.3 Mac Playground?
I referenced from Apple's document - Window Manager Reference, and from the sample code SonofGrab, but I didn't find an answer in obj-C nor Swift.
How should I do it?
回答1:
This should work for NSWindow from CGWindowID
NSWindow * ns_window;
ns_window = [NSApp windowWithWindowNumber: windowNumber];
To get CGWindowID from NSWindow use
CGWindowID window_id = (CGWindowID)[ns_window windowNumber];
来源:https://stackoverflow.com/questions/38801195/how-to-get-window-reference-cgwindow-nswindow-or-windowref-from-cgwindowid-in