I have successfully hacked some tiny applescript together to make a script that goes “ding!” and pops up a dialog box with a text reminder. It has one button, “OK” which clicks to make the dialog box go away. It works well, when I’m at desk. Now, I’ve found that if I’m out of the office, and the dialog (triggered via iCal’s alarm, “Run Script”) runs at the proper time, it throws up this error message:
“An Applescript event alarm did not execute properly. The script “GetSomeWater” was assigned to the event “Water” did not open or did not finish running.”
I suppose that happened because I wasn’t there to dismiss the dialog box. I am unhappy because this is untidy. And throws up another dialog box.
Main Question: So what can I add to the script to make it go away, say after a minute or two, without having been acted on by pressing the OK button?
Here’s the code:
(*
This was stolen from the Script Editor Scripts "About these scripts" script and made into a list dialog box
I want a dialog box that pops up to the front and won't go away until clicked.
*)
beep 3
on beep n
set sys_lib to (path to "dlib" from system domain)
set sound_ref to ("" & sys_lib & "Sounds:ping.aiff") as alias
tell application "Play Sound"
play sound_ref repeat (n - 1)
end tell
return
end beep
tell application "Finder"
activate
display dialog "It's time for a glass of water.
Get up off your lazy bum and go and get a glass of water. Please. It's for your own good health." buttons {"OK"} default button 1 with icon note
end tell
Hi. Sounds like the alarm is timing out waiting for the reminder script to finish.
You need to add “giving up after…” The default is an OK button, so you can leave that out:
tell application "Finder"
activate
display dialog "It's time for a glass of water.
Get up off your lazy bum and go and get a glass of water. Please. It's for your own good health." with icon note giving up after 3 --pause in seconds, experiment to find out how long is too long.
end tell
Another option is a display alert (I think they look nicer.) It uses the icon of the frontmost application, Finder in this case, so you don’t need to specify the icon.
tell application "Finder"
activate
display alert return & "It's time for a glass of water." message "Get up off your lazy bum and go and get a glass of water. Please. It's for your own good health." giving up after 3.
end tell
Thank you all. I’ve not seen that command (not unusual, I know very little about AS). I have now found that the issue is not the applescript, but iCal. It’s the one popping up the “An Applescript event alarm did not execute properly. The script “GetSomeWater” was assigned to the event “Water” did not open or did not finish running.” This happens whether or not the “giving up after” command is in the script. So I’ll just go on looking for something else. At least now I have an idea of what I’m looking for!
This is my new favorite way of making a dialog box that will not time out on you even if it is up on your screen all day:
with timeout of 9999 seconds
display dialog ("It's time for a glass of water." & return & return & "Get up off your lazy bum and go and get a glass of water. Please. It's for your own good health." with icon note giving up after 9990)
end timeout
Model: G5 Tower (not Intel) - Script Editor ver 2.1.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)