【发布时间】:2013-05-22 00:55:52
【问题描述】:
我使用Time Tracker For Mac 作为我的时间跟踪器。它有一个菜单栏项,我希望能够通过键盘快捷键访问它。
我找到了一种使用 GUI 脚本单击项目的方法:
tell application "System Events" to tell process "Time Tracker"
click menu bar item of menu bar 2
end tell
不幸的是,除非我在菜单上操作(即按 Enter 或 Esc 键),否则脚本不会返回成功。所以如果我想触发向下箭头键...
tell application "System Events" to tell process "Time Tracker"
click menu bar item of menu bar 2
-- hangs here forever until menu is closed
tell application "System Events" to key code 124
end tell
脚本永远等待。如果我点击转义,菜单栏项会关闭,然后才会触发向下箭头键。
有点奇怪。我只需要单击菜单栏项不阻止进一步的脚本执行。
有什么建议吗?
【问题讨论】:
标签: applescript