System events

Hi

I’m playing around a little bit with “System Events”. I try to load a text file into a application which doesn’t support AppleScript. I use the following script

tell application "AdForce 4.2.5b3-D"
	activate
	tell Application "AdForce 4.2.5b3-D" to activate
	
	tell Application "System Events"
		
		tell process "AdForce 4.2.5b3-D"
			
			tell menu bar 1
				click menu item "Importieren." of menu "Datei"
			end tell
		end tell
	end tell
end tell


tell application "AdForce 4.2.5b3-D"
	activate
	
	display dialog "Hello World"
	
end tell

The first part works fine (selection and load of the file) but then the script blocks and reports a timeout error after some time.
Is there a way how I can interrupt the script til the file has benn loaded. It works with delay but this couldn’t be the solution.

Thanks in advance for your help

Baschi:cool:

After importing you may check for a known UI element. Eg, if it shows a progress bar with the progress of importation, you could:

delay 1
repeat
	if not (exists window "progress") then exit repeat
	delay 1
end repeat

Or «if exists window “loaded document” then exit repeat», etc.

Hi jj

Thanks a lot - works perfect !!!

Regards, Baschi