【发布时间】:2010-03-01 03:17:26
【问题描述】:
我正在尝试使用 AppleScript 向应用程序 VisualBoyAdvance 发送击键,但我无法让它工作。
到目前为止,我的代码是这样的:
tell application "VisualBoyAdvance"
activate
tell application "System Events"
keystroke "k"
end tell
end tell
当我直接告诉 VisualBoyAdvance 时,我得到了这个错误:
error "VisualBoyAdvance got an error: Can’t get keystroke \"k\"." number -1728 from keystroke "k"
我尝试过直接告诉 VisualBoyAdvance,我也尝试过使用key code 40,但我仍然无法让它工作。奇怪的是,这确实有效:
tell application "VisualBoyAdvance"
activate
tell application "System Events"
keystroke "d" using {command down}
end tell
end tell
但这是显示在菜单栏中的键盘快捷键,所以我想它会有点不同。
如何使用 AppleScript 模拟按键并让应用程序响应?如果我不能为此使用 AppleScript,我还能使用什么?
【问题讨论】:
-
您是否开启了辅助设备支持?
标签: automation macros applescript