2
votes

I'm trying to run an applescript application on Mac OSX that automatically takes a picture with photobooth. It isn't working. The keystroke for taking a picture is "command" and "return".

Here is my script so far:

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

3 Answers

1
votes

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

0
votes

If you wanted an instant photo you could use this instead:
tell application "Photo Booth"
activate
end tell
tell application "System Events"
delay 3
keystroke return using {command down, option down}
end tell

-1
votes

This will make it go a bit faster when Photo Booth is already opened.

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