开发者_StackOverflowIn Cocoa/ Objective C I need to be able to programmatically find out which app or process has the keyboard focus. This may be done by doing a 'hit-test', but I'm not exactly sure.
I also need to get the process ID number and Window Title of app that has the keyboard focus.
Objective C or C only please!
Snippets appreciated!
You can use [NSWorkspace sharedWorkspace] activeApplication to find the front application. The Accessibilty API can be used to look inside the application to get window titles etc.
Another option is to use the Quartz Window Services function CGWindowListCopyWindowInfo() to get a list of all windows
精彩评论