Sunday, January 21, 2018

#1 2011-03-23 10:27:52 am

pradeepkrishnan
Member
Registered: 2011-03-08
Posts: 6

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 

OR

2. 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.

Thanks,
Pradeep

Offline

 

#2 2011-03-23 06:26:59 pm

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2728
Website

Re: Applescript timeout when screen is locked

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:

Applescript:

try
   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

Offline

 

#3 2011-03-25 09:32:39 am

pradeepkrishnan
Member
Registered: 2011-03-08
Posts: 6

Re: Applescript timeout when screen is locked

@DJ thanks for your time..

It times out at many Finder commands.
Example:

Applescript:

set movie_files to every file of movie_folder_path
       
       repeat with movie_file in movie_files
           with timeout of 27000 seconds
               try
                   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?

Offline

 

#4 2011-03-25 06:14:08 pm

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2728
Website

Re: Applescript timeout when screen is locked

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):

Applescript:

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

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)