在automator中使用apple脚本执行键盘快捷键

时间:2013-01-09 22:34:23

标签: applescript

我是第一次在automator中使用苹果脚本。我希望脚本在先前启动的应用程序中执行键盘快捷方式。

on run
activate application "MacCaption"
tell application "MacCaption"
    keystroke "x" using command down

end tell

我得到语法错误预期行结束但在单词上找到了标识符。

2 个答案:

答案 0 :(得分:3)

您的问题是keystroke必须通过系统事件。之一:

tell app "System Events"
    keystroke "x" using command down
end tell

tell app "System Events"
    tell process "MacCaption"
        keystroke "x" using command down
    end tell
end tell

没有真正的区别,但你需要系统事件。

答案 1 :(得分:1)

尝试:

tell application "System Events" to keystroke "x" using command down
相关问题