5

我试图找出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

所以我只需要一种方法来在这个循环期间从所说的“菜单项”中打印/收集快捷方式。

谢谢你的帮助!

4

1 回答 1

7

看起来键盘快捷键信息可用作每个菜单栏项的属性:

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"}

这里有一些属性及其值的详细说明,这里详细的参考。

于 2009-11-08T01:45:15.987 回答