Applescript timeout when screen is locked

My applescript goes into a timeout mode when it runs and the screen of the machine is locked. To be more precise, it waits for the screen to be unlocked before executing the next ‘Finder’ command.

  1. I cant increase the timeout since nobody can look into this machine periodically


  1. I cant use ‘ignoring application responses’ every place it can potentially timeout.

How can I resolve this ScreenSaver wait and timeout issue? Running out of ideas please help.


It seems you’re asking the same question en didn’t solve it yet. What is the command where the script is hanging. Any normal command would be executed if the screen is off or if the screen saver is up. So it would be more usefull if you could tell us the exact line of code of the script is hanging. You can also wrap a try catch around the timeout event like this:

	with timeout of 2 seconds --change the time to a reasonable time window
		--do something
	end timeout
	set x to true
on error
	--command(s) took too much time
	set x to false
end try

if not x then
	--command didn't work
	return --or do something else like unlocking the screen with a keystroke for example
end if

@DJ thanks for your time…

It times out at many Finder commands.

set movie_files to every file of movie_folder_path
		repeat with movie_file in movie_files
			with timeout of 27000 seconds
					capture_display_image(movie_file as alias) of me
					delete movie_file
				on error err_txt number err_num
					log_msg(err_num & ":E102:" & err_txt) of me
				end try
			end timeout
		end repeat

In the script above the Apple event times out at ‘delete movie_file’.

Also, it is best if I can do it without unlocking the screensaver through the AppleScript. I think the only way out is to instruct AppleScript to not to wait for screensaver, to skip it probably. Is this possible?

Well my simplest suggestion will be “ if it is the Finder that gives you the trouble (I was expecting another command that was triggering the problem) “ to step over to the shell. Everything that is possible in the Finder is also possible in the shell. This also seems for me why I never have these problems because I use a lot of scheduled applescripts but never uses them with the Finder “ mostly they only run a couple of shell commands.

to delete a file use rm, to move a file end/or rename use mv and to copy a file use ditto(equivalent to finder’s copy). to remove your file simply use (ouside a tell block):

do shell script "rm -f " & quoted form of posix path of movie_file