I have a very simple apple script which runs other apple scripts in a sequence. The problem is that my script “Kill All” is starting (and killing everything) before the preceding script “Amazon DL” has finished the last of its jobs.
try
tell application "Amazon DL" to activate
end try
try
tell application "Kill All" to activate
end try
Is there a simple way, other than using a delay, to ensure that the first script has actually done all its work before the second script activates?
Most of the time, if the script is creating a file, I use a loop checking the size of this one.
When the size no longer change the task is achieved.
Alas here we have no info about what your script is doing.
Yvan KOENIG (VALLAURIS, France) mardi 18 septembre 2012 10:21:08
The controlling script’s invoking the “Kill All” applet as soon as the “Amazon DL” one has been activated, not after it’s then run its script code. To get scripts to run sequentially, you need something like this:
set Amazon_DL to (load script file "path:to:Amazon DL script") -- Use the real path here.
run script Amazon_DL
set Kill_All to (load script file "path:to:Kill All script") -- Ditto.
run script Kill_All
In this case, Amazon DL and Kill All don’t need to be saved as applications.
If Amazon DL contains any instructions which don’t wait for replies, it’s still possible that Kill All will kick off prematurely.