wait for application to fully load before proceeding with script?

I am trying to write a simple applescript that boots up eclipse, waits for it to be completely booted up, and then quits.

tell application “Eclipse” to activate
– wait until eclipse is fully booted up
tell application “Eclipse” to quit

I realize I can use “delay x” to have a pause on the commented line. However, that technique is not sustainable, as the boot up time (for my setup) will vary considerably. This is NOT the solution I am looking for.

I tried waiting for the version number or something, like in this post (http://macscripter.net/viewtopic.php?id=27050). However, the version number is available long before the boot sequence completes.

I have seen a few other postings that waited for a window with a particular name to appear, but that does not seem to work for eclipse. For example, the output of:

tell application “Eclipse”
set windowName to name of front window
end tell

Is a dialog box with “Eclipse got an error: Can’t get name of window 1.”

Any help would be appreciated!

Thanks,

Caitlin

Hi. I’m wondering why you would want to do this, but try:

tell application "Eclipse" to (launch) quit

Marc Anthony,

I am planning to add a few actions before quitting, but I am trying the simplest thing first – just booting up and shutting down.

The suggested script:

tell application “Eclipse” to (launch) quit

does not work. The quit signals goes out before the first phase of launching has completed and trips an AppleScript error. I also have tried looping until the quit signal no longer causes an error:

repeat
try
tell application “Eclipse” to quit
exit repeat
on error
delay 2
end try
end repeat

but this quits Eclipse before it has completely booted: the workspace has still not appeared.

Caitlin

I don’t know Eclipse but you may try:


tell application "Eclipse" to activate
tell application "System Events"
	repeat
		delay 0.2
		if name of every application process contains "Eclipse" then exit repeat
	end repeat
end tell

Yvan KOENIG (VALLAURIS, France) mercredi 16 septembre 2009 21:40:46

Yvan Koenig,

Nope. It still exists the loop too early:

“Eclipse got an error: can’t continue quit.”

At the point when Eclipse gets the quit signal, it is too early in the boot process. In fact (see my prior reply) the point where sending the quit signal to Eclipse stops causing an error is still too early in the boot process.

I feel like the script really needs to wait until an Eclipse window appears, but I have not been able to successfully do that.

Caitlin

Maybe:


tell application "Eclipse" to activate

tell application "System Events" to tell application process "Eclipse"
	repeat
		delay 0.2
		if (count of windows) > 0 then exit repeat
	end repeat
end tell

It works with several apps. I don’t know for Eclipse.

Yvan KOENIG (VALLAURIS, France) jeudi 17 septembre 2009 21:24:29