Entourage GUI Scripting

I’ve written a GUI script to customize HTML emails in Entourage. It decreases the indent (up to 3 times) and changes the text color to navy, the font to Geneva, and the font size to Medium. It compiles fine and does its job perfectly when run from Script Editor. My problem is that it hangs with the Format menu open (or just highlighted sometimes) when I run it from Entourage’s Script menu. Any ideas? I’m using Panther 10.3.3 and I’ve activated access for assistive devices.


tell application "System Events"
	tell process "Microsoft Entourage"
		set frontmost to true
		tell menu "Format" of menu bar item "Format" of menu bar 1
			try
				click menu item "Decrease Indent"
				click menu item "Decrease Indent"
				click menu item "Decrease Indent"
				click menu item "Navy" of menu "Color" of menu item "Font Color"
				click menu item "Geneva" of menu "Font" of menu item "Font"
				click menu item "Medium" of menu "Size" of menu item "Font Size"
			end try
		end tell
	end tell
end tell

Thanks,

Bryan

Try adding some ‘delay’'s:


tell application "System Events"
	tell process "Microsoft Entourage"
		set frontmost to true
		tell menu "Format" of menu bar item "Format" of menu bar 1
			try
				click menu item "Decrease Indent"
				delay 1
				click menu item "Decrease Indent"
				delay 1
				click menu item "Decrease Indent"
				delay 1
				click menu item "Navy" of menu "Color" of menu item "Font Color"
				delay 1
				click menu item "Geneva" of menu "Font" of menu item "Font"
				delay 1
				click menu item "Medium" of menu "Size" of menu item "Font Size"
			end try
		end tell
	end tell
end tell

I was able to reprodue the problem, and the foregoing fixed it for me. You might try experimenting with which ‘delay’'s are strictly necessary, and how long they have to be. The interval can be a real, so values like .5 will work, at least in sufficiently recent versions of AS.