在applescript中,如何访问菜单项的键盘快捷键? [英] In applescript, how can I access the keyboard shortcut of a menu item?

查看:26
本文介绍了在applescript中,如何访问菜单项的键盘快捷键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出 Applescript 中给定菜单项的键盘快捷键(例如,shift+cmd+S).探针菜单栏"脚本帮助我访问菜单项,甚至检查它们的属性等,但我一直无法发现其中哪些会打印出键盘快捷键.

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.

探针脚本是这样的:

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.

感谢您的帮助!

推荐答案

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

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

here 和详细参考此处.

这篇关于在applescript中,如何访问菜单项的键盘快捷键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆