Applescript中的击键

时间:2014-12-14 19:47:14

标签: macos applescript

我正在尝试在Mac OSX上运行一个带有photobooth图片的AppleScript应用程序。它不起作用。拍照的按键是“命令”和“返回”。

到目前为止,这是我的脚本:

tell application "Photo Booth"
    activate
end tell
tell application "System Events"
    delay 3
    keystroke "return" using command down
end tell

3 个答案:

答案 0 :(得分:1)

tell application "Photo Booth"
activate
end tell
tell application "System Events"
delay 3
keystroke return --does not need the command
end tell

答案 1 :(得分:0)

如果你想要一张即时照片,你可以使用它:
告诉申请" Photo Booth"
激活
告诉你 告诉应用程序"系统事件"
延迟3
按键返回使用{命令向下,选项向下}
结束告诉

答案 2 :(得分:-1)

当Photo Booth已经打开时,这将使它更快一些。

on is_running(appName)
    tell application "System Events" to (name of processes) contains appName
end is_running

set safRunning to is_running("Photo Booth")
if safRunning then
    tell application "Photo Booth" to activate
    delay 0.3
    tell application "System Events" to keystroke return using command down
else
    tell application "Photo Booth" to activate
    delay 3
    tell application "System Events" to keystroke return using command down
end if