开发者

How to access windows hierarchy for my application on Mac?

开发者 https://www.devze.com 2023-01-04 01:22 出处:网络
I mean all the windows which belong to my application (process). I need to get something like (NSWindow *) for all of them. Notice, some windows were created by third-party plug-ins and are not access

I mean all the windows which belong to my application (process). I need to get something like (NSWindow *) for all of them. Notice, some windows were created by third-party plug-ins and are not accessible by [NSApp windows]. Yes, I know, Quartz Window Services can return all the windows b开发者_JAVA技巧y PID. But how can I get NSWindow by CGWindowID then? Thanks!


Try NSWindowList to get window numbers, and then -[NSApplication windowWithWindowNumber:] to get NSWindows.


Usually NSWindowList() will give window ids. Also there're Quartz Window Services to help.

  • To get NSWindow* (Cocoa) there's [NSApp windowWithWindowNumber: (NSInteger)windowID] method.
  • To get WindowRef (Carbon) there's HIWindowFromCGWindowID() function.

If both of the above do not work, that means the window was created with CoreGraphics Private API. Its definition is available thanks to reverse engineering.

Concerning X11 windows on Mac, they are created with Xplugin library (by Xquartz) which is closed source and also uses CoreGraphics Private API.

0

精彩评论

暂无评论...
验证码 换一张
取 消