Time Lapsed Photography in Aperture using AppleScript

I was playing around with Time Lapse Photography recently. Looking for a way to do it on the cheap. Automator has a nice way of doing this, using the action Take Picture or Take video snapshot (see Automator for the difference between the two).

Unfortunately not all cameras are supported by the Automator action and as it turned out my camera, a Canon 40D is one of them. But is is supported by Aperture's tethered shooting so I cobbled together this AppleScript.

Apertures support of AppleScript is not as strong as some other programs. Specifically for this application there is no way to directly access the tethered shooting capabilities of Aperture via AppleScript. So UI Scripting had to be employed. In UI scripting the script pretends its a user manipulating the programs UI elements. In this case it was fairly straight forward only one menu and two levels.

Before running the script have your camera attached and ready, create and select the project that you want the shots to go into. Also while the script is running make sure Aperture ad the Tether HUD maintain the focus.

Either cut and paste the code form here or else download the attached script.

Note: For this script to run you need to enable Enable access for assistive devices in System Preferences under Universal Access. This is a quirk of Applescript when doing GUI scripting.
enjoy!

(*
	©2011 Frank Caggiano
	
	Time Lapsed Tethered Shooting in Aperture
	
	Create and select Aperture destination project for the tethered shots before runnig this script.

*)
set delayTime to 10 -- Number seconds between shots
set totalShots to 5 -- Number of shots to take


tell application "Aperture" to activate
tell application "System Events"
	tell process "Aperture"
		click menu item "Start Session…" of menu 1 of menu item "Tether" of menu 1 of menu bar item "File" of menu bar 1
		
		click button "Start Session" of window "Tether Settings"
		delay 1
		click button "Capture" of window "Tether"
		
		repeat (totalShots - 1) times
			delay delayTime
			click button "Capture" of window "Tether"
		end repeat
		delay 1
		click button "Stop Session" of window "Tether"
	end tell
end tell
AttachmentSize
Tethered.scpt4.86 KB