在AppleScript的,我怎么能访问菜单项的快捷键? [英] In applescript, how can I access the keyboard shortcut of a menu item?

查看:219
本文介绍了在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"}

有属性的一些阐述和值这里和详细的参考<一href=\"http://developer.apple.com/mac/library/documentation/Accessibility/Reference/AccessibilityCarbonRef/Reference/reference.html\">here.

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

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