你必须修改它以适合你的特定应用程序。
运行这些独特的脚本编辑器,检查结果:
tell application "System Events" to menu bar items of every menu bar of ¬
process "SystemUIServer"
。
tell application "System Events" to value of attributes of menu bar items of menu bar 1 of ¬
process "SystemUIServer"
。
tell application "System Events" to value of attributes of menu bar 1 of ¬
process "BetterTouchTool"
这里是你如何从BetterTouchTool单击首选:
tell application "System Events" to tell process "BetterTouchTool"
click first menu bar item of menu bar 1
click menu item 1 of menu 1 of menu bar item of menu bar 1
end tell
这里是你如何在机场,向WiFi关闭:
tell application "System Events" to tell process "SystemUIServer"
click (first menu bar item whose value of attribute "AXDescription" contains "Wi-Fi") ¬
of menu bar 1
try
click menu item 2 of menu of ¬
(first menu bar item whose value of attribute "AXDescription" contains "Wi-Fi") of ¬
menu bar 1
end try
end tell
Accessibility Inspector
是你的朋友。
菜单栏是SystemUIServer核心服务的一部分,我没有在其中看到任何AppleScript字典。如果你喜欢冒险,你可以通过在自己的代码中注入''[NSMenuToolbar _setCurrentMenuItem:]'方法来玩,但它不适合心脏不好。 – 2014-10-21 23:17:06