在applescript中,如何访问菜单项的键盘快捷键?

发布于 2024-08-11 00:24:11 字数 384 浏览 8 评论 0 原文

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

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

感谢您的帮助!

I'm trying to figure out the keyboard shortcut (e.g., shift+cmd+S) of a given menu item in Applescript. The "Probe Menu Bar" script has helped me to access the menu items and even inspect their properties and such, but I've been unable to discover which of these will print out the keyboard shortcut.

The probe script is like this:

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

So I just need a way to print out / collect the shortcut from said "menu item" during this loop.

Thanks for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

下壹個目標 2024-08-18 00:24:11

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

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

有一些属性及其值的详细说明此处和详细参考此处

It looks the keyboard shortcut information is available as attributes of each menu bar item:

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

There's some elaboration of the attributes and their values here and detailed reference here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文