UI Scripting in Illustrator CS2 - accessing menus & UI elements

Hi all -

A year or two ago I created a script to do some drawing adjustments and then export to several different file types that I needed. However, firing up the same script in CS2 results in the NSReceiverEvaluation error - “I can’t find what you’re looking for!” - wherever the script was meant to click on a menu, button or popup. (keystrokes still work lovely)

I’m using the code generated by Prefab’s UI browser targeted at Illustrator CS2 (which is still able to pull the menu information out of Illustrator) but it refuses to do it. I’ve not experienced this problem when UI scripting in other applications or with the CS version of Illustrator. I’ve migrated most of the script to alternate means but I can’t seem to get to everything. I know I could record an action, but I’d prefer this to not require any prior set up if it happens to be run on a different computer.

Has anyone else had this problem? Any solutions?

The code I’m testing with is (direct from UI browser - click selected element with safe tell wrapper):

activate application "Adobe Illustrator"
tell application "System Events"
	get system attribute "sysv"
	if result is greater than or equal to 4144 then -- Mac OS X 10.3.0
		if UI elements enabled then
			tell application process "Illustrator"
				click menu item "Stroke Color" of menu 1 of menu item "Same" of menu "Select" of menu bar item "Select" of menu bar 1
				
			end tell
		else
			beep
			display dialog "GUI Scripting is not enabled" & return & return & "Open System Preferences and check Enable Access for Assistive Devices in the Universal Access preference pane, then run this script again." with icon stop
			if button returned of result is "OK" then
				tell application "System Preferences"
					activate
					set current pane to pane "com.apple.preference.universalaccess"
				end tell
			end if
		end if
	else
		beep
		display dialog "This computer cannot run this script" & return & return & "The script uses GUI Scripting technology, which requires an upgrade to Mac OS X 10.3 Panther or newer." with icon caution buttons {"Quit"} default button "Quit"
	end if
end tell

It always fails on the click line

Thanks!

Model: iMac G5
Browser: Firefox 1.0.7
Operating System: Mac OS X (10.3.9)

hi

can you not put in a line of code which selects every stroke of of a certain color instead of Gui scripting it?

Yes, I’m working on that right now. I guess a better example would be exporting to DXF (or other file type not included as an export file as ___" option). I scoured the web for direct exporting to DXF with applescript, but couldn’t find anything. I ended up recording an action and playing it with applescript amid regular “export as” lines.

No need to scour the web, just look in the dictionary. The file formats supported in Illus CS2 export are:

Flash
GIF
JPEG
Photoshop
PNG24
PNG8
SVG

Looks like no joy for DXF export directly thru scripting. :confused:

In case you still needed an example of “Select Same Stroke”, try this to match a manually selected path:


tell application "Adobe Illustrator"
	tell document 1
		try
			set targetColor to stroke color of item 1 of selection
			set properties of every path item whose stroke color is targetColor to {selected:true}
		end try
	end tell
end tell