event timed out

How do I control the time before an Apple Event times out?

When running a script that prompts a user for input, by default the system will display the "Event Timed Out" dialog after two minutes. Then, the user can only hit Return and the script quits without the input or consequent output.

I'd like to both control the amount of time before an event will time out and to change the action when an event times out -- for example, launch iTunes and play a particular song or have the computer "beep" every two seconds.

Posted on Sep 29, 2005 7:56 AM

Reply
3 replies

Sep 29, 2005 9:00 AM in response to Randy Silvers

Randy,
There are a couple of options for you to consider.
To timeout a dialog:
display dialog "hello" giving up after 3 -- time in seconds

To change the default AppleScript timeout. This is usually used for commands which take a long time, like copying large file(s).
with timeout of 3 seconds
--command which may not work
end timeout

Or you can us 'try' for a command which you expect may fail, like copying a file which may not fit on the target disk:
try
--command
on error
--alternate command
end try

Reese

Sep 29, 2005 11:29 AM in response to Randy Silvers

There are two aspects to your question that might help.

First of all, there is no default timeout on display dialog, so the script shouldn't timeout after 2 minutes - it should sit there indefinitely.

For example, try this script and see what happens:

display dialog "waiting..."

beep


It will sit there indefinitely.

Timeouts only come into play when in a 'tell application' block, and it relates to how long AppleScript will wait for that app to execute the command.

Therefore, this script will timeout:

tell application "Finder"

display dialog "waiting..."

beep

end tell

Now this will timeout after two minutes, but it's the 'tell application' that's timing out, not the display dialog.

So your first solution is to ensure the display dialog command is not in any 'tell' block.

Secondly, if it needs to be in a tell block, you can use a try/end try block to catch the timeout expiring.

When the script times out, AppleScript throws a -1712 error which you can trap:

try

tell application "Finder"

display dialog "waiting..."

end tell

on error number errNo

if errNo = -1712 then -- timeout!

display dialog "Oops. Time's up!" buttons {"OK"} default button 1

end if

end try

Sep 29, 2005 11:48 AM in response to Randy Silvers

-The following works on Tiger...
-- Save the script as a "Stay Open" application --
-- Make certain there is a space after the word " Cancel " (for the dialog box) --
-- Give it a try on your OS - - Tom --
--
set myPath to text
display dialog "Tell application iTunes to open and play..." buttons {" Cancel ", "Open"} ¬
default button 2 giving up after 120 -- or whatever
if the button returned of the result is "Open" then
tell application "iTunes" to activate ( play)
end if

set myPath to path to me
quit --

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.

event timed out

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