Countdown Clock

Here’s a simple solution to a simple problem: how to create a timer that counts down from a specified number of minutes to zero, by seconds? Assuming one slide per second of time counted, a two-minute timer would require the creation and the setting transition parameters for 121 slides!

Ah, but there are the joys and rewards for using Automation. The script provided here will create the presentation in seconds.

The Presentation

For your countdown Keynote presentation, you’ll want to use a monospace font, like Menlo Bold (shown in the movie above), and align the text to the right so that the time characters do not shift position as the countdown progresses.

The script will duplicate the slide and adjust the displayed time accordingly to count down to “:00” Any slide transition settings and timing will be handled by the script.

DO THIS ► DOWNLOAD  the example Keynote presentation file. Select the first slide and replace the current number of minutes with the desired number. Then, run the provided script. Add your own ending and voila!

The Script

Here is the script for creating a countdown presentation based on the current slide of the frontmost Keynote presentation.

tell application "Keynote"
 tell front document
 set startingSlide to current slide
 duplicate (get current slide)
 tell the last slide
 set slideText to object text of the default title item
 -- get the minutes and seconds
 if slideText begins with ":" then
 set amountInMinutes to "0"
 set amountInSeconds to first word of slideText
 set amountInMinutes to first word of slideText
 set amountInSeconds to second word of slideText
 end if
 -- adjust seconds
 if amountInSeconds is "00" then
 set newSeconds to "59"
 -- adjust minutes
 if amountInMinutes is "0" then
 set newMinutes to ""
 set newMinutes to ¬
 ((amountInMinutes as integer) - 1) as string
 if newMinutes is "0" then set newMinutes to ""
 end if
 set newSeconds to ¬
 ((amountInSeconds as integer) - 1) as string
 if length of newSeconds is 1 then
 set newSeconds to "0" & newSeconds
 end if
 -- adjust minutes
 if amountInMinutes is "0" then
 set newMinutes to ""
 set newMinutes to amountInMinutes
 end if
 end if
 -- set the text
 set newTime to newMinutes & ":" & newSeconds
 set object text of the default title item to newTime
 if newTime is ":00" then exit repeat
 end tell
 end repeat
 -- set the transition of all slides
 set the transition properties of every slide to {transition effect:no transition effect, transition duration:0, transition delay:1, automatic transition:true}
 end tell
 -- start the presentation
 start front document from startingSlide
end tell