How to programmatically determine the currently active App in OS X?

允我心安 提交于 2019-12-08 09:54:21

问题


I have a simple statusbar applicationn which work in background. I want to know which app currently is active.

It is possible?


回答1:


Take a look at the NSRunningApplication class and its active property (I've linked the documentation for you). You can look at an array of running applications and find the one that's "active".

Oh, and to get that array of running applications, you can do that via [NSWorkspace currentWorkspace] runningApplications].

Hope this helps!



来源:https://stackoverflow.com/questions/10143540/how-to-programmatically-determine-the-currently-active-app-in-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!