开发者

Get Open Windows in Objective C

开发者 https://www.devze.com 2023-01-26 07:36 出处:网络
How would I get the names of the open w开发者_JAVA百科indows on Mac OSX in Objective C? Basically I just want to check if a window with a specific name (ie. \"Chrome\" to detect if Chrome is open) is

How would I get the names of the open w开发者_JAVA百科indows on Mac OSX in Objective C? Basically I just want to check if a window with a specific name (ie. "Chrome" to detect if Chrome is open) is open.

The app in question will NEVER run without a window open (unlike Chrome in my example), so detecting running processes may not be necessary.


For the case you describe, looking through the window list is not a good approach. For example, Chrome does not have a window named "Chrome" AFAIK — the names of its windows depend on the currently open tab. If you want to detect an application, use NSWorkSpace's launchedApplications method.

To actually detect windows, use the Quartz Window Services API.

0

精彩评论

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