我正在尝试访问OS中NSRunningApplication对象的菜单。它有一个ownsMenuBar @属性,但是没有一个实际菜单栏的实例(这是有意义的)。相反,我很好奇如何访问NSRunningApplication知道的菜单栏。也许是KVO?NSRunningApplication和NSApplication之间是否有任何(甚至很小的)关系
谢谢!
-编辑
djai djan,你帮了我很大的忙,这是我根据你的建议编写的代码!
tell application "System Events"
return menu bar of first process where frontmost is true
end tell发布于 2012-12-28 09:59:37
NSRunningApplication和NSApplication之间没有关系
但是你可以通过applescript (你可以把它桥接到cocoa)来获得它需要UI脚本
例如,脚本为:
tell application "System Events"
set m to menu bar 1 of application process "Notification Center"
end tell请参阅:https://developer.apple.com/documentation/Cocoa/Conceptual/ScriptingBridgeConcepts/index.html
https://stackoverflow.com/questions/14063601
复制相似问题