I am running AS on OS 8.6 and trying to make proper use of one of the Sleep Commands
The following is my script:
set restoreIcons to file "Paul:Utilities:Apple Script:Scripts (In Use):Restore the Icons"
run script restoreIcons as alias
--tell me to sleep while someone is using file restoreIcons as alias checking every 60
--sleep while someone is using file restoreIcons as alias checking every 60
--tell me to sleep while someone is using file restoreIcon checking every 60
--sleep while someone is using file restoreIcons checking every 60
tell application "Finder" to display dialog "Yes"
The script runs the “Restore Icons” script just fine. But what I am trying to do is have the script “wait” 60 seconds after completing “Restore Icons” before the Finder displays the dialog box.
The problem is that Finder displays the dialog within 1-2 seconds of completing “Resore Icons” script no matter which line I uncomment.
Add this to the end of your Restore the Icons script:
return true
Then try this:
set restoreIcons to "Paul:Utilities:Apple Script:Scripts (In Use):Restore the Icons" as alias
set scriptComplete to run script restoreIcons
if scriptComplete is true then
tell application "Finder" to display dialog "Yes"
end if
If “Restore the Icons” takes too long to execute, you might need to adjust the timeout of the script above.
First of all, Thanks to Rob I can now accomplish what I need to do (your script with the change to “Restore Icons” works.The Resotre Icons only takes < 30 seconds to run so the timeout should not be needed.
However I would still like an understanding of why my initial try didn’t work. This would enlighten me on the use of the osaxen.
Anyone who can shed light on this please post.
Thanks again for Rob.
The only ‘sleep’ command that I’m familiar with has nothing to do with putting a script to sleep and everything to do with putting a computer to sleep. Which osax are you using that includes a ‘sleep’ command?
Regarding your script, I just noticed that you want it to wait for 60 seconds after the external script has finished. The following code should accomplish this. Note the use of the delay command - I think this might do what you are asking the sleep command to do.
set restoreIcons to "Paul:Utilities:Apple Script:Scripts (In Use):Restore the Icons" as alias
set scriptComplete to run script restoreIcons
if scriptComplete is true then
delay 60 -- seconds
tell application "Finder" to display dialog "Yes"
end if
For the record, ‘display dialog’ doesn’t require the Finder, although it isn’t necessarily wrong to use it that way. Also for the record, my opinion of the delay command is that it sucks because it tends to hog resources during the delay. Unfortunately, it is sometimes the only option, but I recommend that it be used sparingly.
– Rob (who now runs OS X and has forgotten about many pre-OS X osaxen)
Caught the missing delay and already added it.
I recogized that Finder is not needed for the display dialog but I want the Finder to display the dialog.
I agree that delays are to be avoided but it is necessary in this case, It’s a long story.
Finally for your reference the Sleep Cammands Osaxen is at: