Clock.app stop timer

How can I press the Done button of a timer in Clock.app with AppleScript?

I’m trying to kill the timer at a certain time. It could even be via Terminal if that’s possible.

Here is the script. It is bug ridden to get to the correct button. Don’t ask why.

tell application "System Events"
	tell application process "Clock"
		if (value of radio button 4 of radio group 1 of group 1 of toolbar 1 of window 1) as boolean then -- "Timer" is chosen
			if enabled of button 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of window "Clock" then
				click button 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of window "Clock"
			end if
		end if
	end tell
end tell
1 Like

@whelancg
Here is different approach it works on my machine.
It works by using the zoom and x, y coordinate to click button “Done”.

tell application "System Events" to tell application process "Clock"
	set frontmost to true
	tell menu bar item "Window" of menu bar 1
		click menu item "Zoom" of menu 1
	end tell
	-- You could use Digital Colour Meter to get x, y for button "Done"
	click at {675, 920} -- this is corrent on my machine
	tell menu bar item "Window" of menu bar 1
		click menu item "Zoom" of menu 1
	end tell
end tell
1 Like