-编辑
有一个名为Keycue的应用程序可以执行此功能。
-/编辑
-编辑编辑
这是一个复制品。Get a list of all shortcuts from another application
-/编辑编辑
我正在努力编写一个应用程序来获取最前面应用程序的菜单栏(例如,如果Safari是打开的,则是safari菜单,如果XCode是打开的,则是Xcode菜单),并解析其中的快捷方式。
到目前为止我已经尝试过的东西,但都失败了:
1:花了一周的时间学习applescript。玩弄“系统事件”来获取菜单栏,但是没有我可以收集到的信息,可以给我快捷方式代码。
2:考虑尝试使用NSWorkspace进行KVO。尝试获取NSRunningApplication,但只有一个ownsMenuBar属性,该属性是BOOL,而不是NSMenu。
3:已尝试从NSWorkspace、NSBundle和NSRunningApplication获取NSApplication。一切都无济于事。
4:尝试从applescript获取NSMenu (未成功)。
我想我要尝试的下一件事是搜索ownsMenuBar为YES的NSRunningApplication,然后尝试从..中获取相应的NSApplication。在某个地方。不过还不知道在哪里。
那么有什么建议吗?
发布于 2013-01-18 04:16:01
尝试:
tell application "System Events"
set frontProcess to name of first process whose frontmost = true
tell process frontProcess
get every menu item of menu 1 of menu bar item 2 of menu bar 1
end tell
end tell编辑
一旦有了这个列表,您就可以解析每个菜单项的属性:
tell application "System Events"
set frontProcess to name of first process whose frontmost = true
tell process frontProcess
set myMenuItems to get every menu item of menu 1 of menu bar item 2 of menu bar 1
set myList to {}
repeat with aMenuItem in myMenuItems
set end of myList to aMenuItem's name
set end of myList to value of aMenuItem's attribute "AXMenuItemCmdChar"
set end of myList to value of aMenuItem's attribute "AXMenuItemCmdModifiers"
end repeat
end tell
end tellhttps://stackoverflow.com/questions/14386167
复制相似问题