Automator - timer or countdown to next step/action

I am trying to write an automator action that gives a warning and then counts down to the next action.
This is to link in with an action I have written to automatically close and back-up my Bento database.
What I am looking for is an action in case I forget to activate that action before I quit working in the evening. The action I am looking for should pop up a message and say e.g. 'Bento will close in xxx seconds' and if no button is pressed to cancel, it will then go to the next step and close Bento.
Any suggestions?

MacBookPro 15'

Posted on May 29, 2009 9:51 AM

Reply
3 replies

May 29, 2009 10:36 AM in response to DrOilbert

The standard Wait for User Action action goes the other way (it stops the workflow), so there isn't anything handy that has a built-in counter. You can fake one with a Run AppleScript action though, by popping up dialogs with short timeouts, for example:

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into an Automator 'Run AppleScript' action">
on run {input, parameters} -- countdown dialog

set WaitTime to 10 -- this is the overall time to wait
set Interval to 1 -- this is the interval between dialogs

repeat with Timer from WaitTime to 1 by -Interval
if Timer ≤ Interval then set Interval to Timer
set DialogResult to display dialog return & "Bento will close in " & Timer & ¬
" seconds..." buttons {"Cancel", "OK"} default button "OK" giving up after Interval
if (button returned of DialogResult) is "OK" then exit repeat
end repeat

return input
end run
</pre>

May 29, 2009 11:50 AM in response to DrOilbert

a somewhat different approach from red_menace.

make the following "run apple script" action

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run {input, parameters}

display dialog "Bento will close in 10 seconds" buttons {"Cancel", "Ok"} default button 2 giving up after 10

set theResult to result

set giveUp to (gave up of theResult)
set theButton to (button returned of theResult)
if theButton is "Ok" then
return "proceeding"


end if
if giveUp is true then
return "proceeding"
end if

end run</pre>



followed by the action "stop if input is empty". this can be followed by your action that quits bento.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator - timer or countdown to next step/action

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.