GUI scripting & Illustrator CS

This has me stumped. I’m trying to create a script to change the “Color Settings” pref under the Edit menu in Illustrator CS. I found no direct way to do this in its Applescript dictionary so I’m trying GUI scripting. Here’s what I’ve got so far:


tell application "Illustrator CS"
	activate
end tell

tell application "System Events"
	tell application process "Illustrator CS"
-- this part seem to work to bring up the Color Settings dialog
		tell menu bar 1
			click menu item "Color Settings..." of menu "Edit" of menu bar item "Edit"
		end tell
		tell window "Color Settings"
			click pop up button 5
			click menu item "U.S. Prepress Defaults" of menu 1 of pop up button 5 -- this "appears" to work looking at the screen but doesn't hold the setting
			select
			tell button "OK" 
				click   -- this doesn't work at all
			end tell
		end tell
	end tell
end tell

The first part of the script to bring up the dialog works. Choosing the item from the pp up button appears to work, but the setting does not hold. The part to click “OK” and dismiss the dialog does nothing. If I manually click “OK” that’s when I find out that the choice on the pop up menu didn’t stick. If I reopen Color Settings manually, nothing has changed!

Any ideas? I’m new to GUI scripting…
Thanks in advance

Try this :

tell application "Illustrator CS"
	activate
end tell

tell application "System Events"
	tell application process "Illustrator CS"
		tell menu bar 1
			click menu item 24 of menu 4
		end tell
		tell window 1
			click pop up button 5
			click menu item 7 of menu 1 of pop up button 5
			delay 2
			keystroke return
		end tell
	end tell
end tell

ionah, thanks. That addresses the problem of clicking the OK button, I though i tried “keystroke return” but I guess not. Works like a charm!

Unfortunately, still have the problem of the choice in the menu not “sticking”. I shows as selected, but if you immediately reopen the “Color Settings” dialog you see that the change was not made. Very strange. I guess I’ll try the Adobe forums to see if I can get some relpy from them. Something tells me that they will say its a glitch in Apple’s UI scripting interface.

I will post here if I find a solution.

Thanks again.