我正在尝试找出Applescript中给定菜单项的键盘快捷键(例如,shift + cmd + S)。 “探针菜单栏”脚本帮助我访问菜单项甚至检查它们的属性等,但我一直无法发现哪些将打印出键盘快捷键。
探针脚本是这样的:
tell process "Finder"
get every menu bar
tell menu bar 1
get every menu bar item
get every menu of every menu bar item
get every menu item of every menu of every menu bar item
所以我只需要一种方法在这个循环中打印/收集所说“菜单项”的快捷方式。
感谢您的帮助!
答案 0 :(得分:6)
它看起来键盘快捷键信息可用作每个菜单栏项的属性:
tell application "System Events"
get name of menu item 2 of menu 3 of menu bar 1 of process "Finder"
--> "New Folder"
get every attribute of menu item 2 of menu 3 of menu bar 1 of process "Finder"
--> {attribute "AXRole" of menu item "New Finder Window" of menu "File" of menu bar item "File" of menu bar 1 of application process "Finder", [...]
get properties of attribute "AXMenuItemCmdChar" of [...]
--> {value:"N", class:attribute, settable:false, name:"AXMenuItemCmdChar"}
get properties of attribute "AXMenuItemCmdModifiers" of [...]
--> {value:1, class:attribute, settable:false, name:"AXMenuItemCmdModifiers"}