help please: wait for window to close before continuing

Here’s the case, i’m making a script to open a file then close, then open another file, then close, so on…

what code can i use to make the script wait for the first file to close before moving to the next? i’m currently using delays but i need something that would really wait for it to close and not a preset time. if you’re familiar with windows AutoIt, there’s a function called winwaitclose() and im looking for something similar to it.

thanks.
:rolleyes:

G’day Bensonang

What application are you using to open the files with?

Regards

Santa

I usually do this with system events but, depending on the program you are using, there might be a better way.

The basic form is:

tell application "Your App Here"
	tell application "System Events"
		tell process "Your App Here"
			repeat until (not exists window "Window Name")
			end repeat
		end tell
	end tell
end tell

Any, for example, open the .doc file with ms word, .xls with excel, .pdf with acrobat, etc…

thanks