Applescript won't complete when idle

Hi Nigel, thanks for your interest. To answer your questions yes, the applescript was found active and in the dock, and the error message was a standard looking Applescript message.

It appears Ive solved the original problem. Im still confused about why some of my troubleshooting techniques failed miserably, but Im glad to be able to move past this. It turns out the problem was occurring during the repeat loop. Attempting to display a dialog (or repeatedly display a dialog, unsure which) while a screensaver is active produces an “AppleEvent timed out” error.

It seems as though the debug version of my script shouldve been able to report an error in the specified form, and according to the reading Peter provided as well as the basic explanation in the Language guide, the ‘with timeout’ should have had an effect since it was the Finder being asked to display the dialog. Perhaps I am not understanding some of the subtleties involved.

I solved this by running a unix command (killall -9 ScreenSaverEngine) before running the Applescript.

For the sake of understanding though, if anyone knows, I’d be interested in finding out why the ‘with timeout’ and ‘on error’ statements were ineffective.

Thanks to everyone who helped with this.

Hi, rowie718.

Thanks for posting your discovery of the cause of the problem. Knowing that, I’m able to reproduce it exactly. If the screensaver’s running, the script pauses and waits for the first dialog to be displayed. If the screensaver’s quit before the dialog times out, the script continues. Activating the screensaver while the script’s running pauses the script at that point; deactivating the screensaver again allows the script to continue from where it had reached in the count-down.

I haven’t yet looked into the ineffectuality of ‘with timeout’. It would only delay the inevitable if it worked anyway. The ‘on error’ statements are ineffective because they’re trying to display dialogs explaining why the script can’t display dialogs! They’re causing the errors you’ve actually been seeing lately!

Another way to quit the screensaver is:

tell application "System Events" to set screenSaverRunning to (application process "ScreenSaverEngine" exists)
if (screenSaverRunning) then tell application "ScreenSaverEngine" to quit

Possibly less drastic than the shell script, but I haven’t tried either of them with a passworded screen saver.

most successful method for getting the screen saver to stop:

tell application “System Events” to if exists process “ScreenSaverEngine” then keystroke space

seems kluge but i tell ya, its simple and works every time. the killall unix command should work, and does on most computers, but wouldnt work on a couple of clients.