开发者

Which app has keyboard focus?

开发者 https://www.devze.com 2023-01-09 00:55 出处:网络
开发者_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 sur

开发者_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

0

精彩评论

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