The first application is supposed to grab some mails and do some processes on it. So I can’t really predict a delay for it.
The 2nd application is supposed to work on the results of these processes.
Presumably these are script applets you’ve written and there’s some good reason why they can’t be amalgamated into one script.
The “connection invalid” error usually comes about when an application disappears or quits while being sent a script command. Your applets will quit as soon as they’ve done their stuff and this may be having some effect on their feedback to the script you’re using to run them. I’ve had some success with this:
launch application appPath
run application appPath
launch application appPath2
run application appPath2
If the applications really are script applets, you could run their code inside your main script thus:
run script file appPath
run script file appPath2
Actually, no. launch loads an application into memory as a process, but doesn’t run it. run loads an application into memory and runs it. activate loads an application into memory, brings it to the front, and runs it. If the application’s already loaded, already running, or already frontmost, the relevant commands have no effect.
tell application "TextEdit" to launch
--> TextEdit launches (if not already launched) and does nothing.
tell application "TextEdit" to run
--> TextEdit launches (if not already launched) and runs through its startup
--> routine (if not already running), including opening a default window.
tell application "TextEdit" to activate
--> Ditto, but with TextEdit as the frontmost app.
the above code works like a charm.
Thanx for the in dept explanation to the topic! Really appreciate it.
The reason why i used 2 apps is that the 1st one is a common app that is used to parse information out. But for this particular case, i wanted to do more, parse and insert into iCal.