监控苹果“系统事件”含可可
我想知道是否有一种方法可以编写一个 Cocoa 应用程序来侦听操作系统系统事件,例如应用程序启动、窗口切换等。我的想法是观看 [NSNotficationCenter default] 消息,但到目前为止我还没有没能找到很多。有人有什么建议吗?
谢谢!
I was wondering if there was a way to write a Cocoa app that listened for OS system events such as an application launching, a window switches, etc, etc. My thought was to watch [NSNotficationCenter default] for messages but so far I haven't been able to find much. Does anyone have any suggestions?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能感兴趣的一些消息将提供给
[NSWorkspace notificationCenter]
,例如应用程序启动、到达前端或退出时。我不确定你所说的“窗户开关”是什么意思。如果您的意思是更改前面的窗口而不更改前面的应用程序,那么在 Mac 上这通常被认为“与您无关”。
Some messages that might interest you would be provided to
[NSWorkspace notificationCenter]
, such as when apps launch, come to the front, or quit.I'm not sure what you mean by "window switches". If you mean changing which window is in front without changing which app is in front, that's generally considered "none of your business" on the Mac.