GUI Button being clicked, but nothing happens

I am new to this, but I was wondering why my button acts like it clicks (button highlights on and off as if being clicked), but it does nothing. I will post my code. Any help would be greatly appreciated.


tell application "Adobe Illustrator"
	activate
end tell
tell application "System Events"
	tell process "Adobe Illustrator"
		tell menu bar 1
			tell menu bar item "Edit"
				tell menu "Edit"
					pick menu item "Find and Replace..."
					keystroke "boy"
					keystroke tab
					keystroke "girl"
					
				end tell
			end tell
		end tell
	end tell
	tell process "Adobe Illustrator"
		tell window "Find and Replace"
			click button "Done"
		end tell
	end tell
end tell

Thanks in advance!

hi whiteink,

no idea why your click doesn’t work, but I think you can simply replace it by ‘keystroke return’ since this button is default:


tell application "Adobe Illustrator"
   activate
end tell
tell application "System Events"
   tell process "Adobe Illustrator"
       tell menu bar 1
           tell menu bar item "Edit"
               tell menu "Edit"
                   pick menu item "Find and Replace..."
                   keystroke "boy"
                   keystroke tab
                   keystroke "girl"
                   keystroke return
               end tell
           end tell
       end tell
   end tell
end tell

Ah I’m sorry, meant to change that (syptoms of working to late). Wanted the clicked button to be “Find”. Actually that is my exact problem. I can’t get any buttons other than the default buttons to click. I was able to use keystroke return to get the default button to click. Any ideas why the “click” action would make the button appear to click, but then the palette remains and nothing happens?

REVISED SCRIPT

tell application "Adobe Illustrator"
   activate
end tell
tell application "System Events"
   tell process "Adobe Illustrator"
       tell menu bar 1
           tell menu bar item "Edit"
               tell menu "Edit"
                   pick menu item "Find and Replace..."
                   keystroke "boy"
                   keystroke tab
                   keystroke "girl"
                   
               end tell
           end tell
       end tell
   end tell
   tell process "Adobe Illustrator"
       tell window "Find and Replace"
           click button "Find"
       end tell
   end tell
end tell

Please help. I know I am a newbie at this, but I really want to understand this stuff. You guys and gals are great and I really appreciate your help. Thanks in advance!

Hi whiteink,

I have played a little with Illustrator - I am afraid these buttons are simply not scriptable at all. Probably the acessibility support of these UI elements was not properly inplemented by Adobe ;-(.

In my opinion the only workaround could be trying to write your own search and replace routine …

D.

Thank you so much for your help Dominik.
I have pretty much came to the same conclusion. So close yet so far away. It’s just frustrating when you can see the click occur and nothing happens. Do you know how often this sort of thing happens. I mean I though applescript GUI could pretty much script anything. :confused:

Oh well, guess I’ll have to figure out a work-around. Like I said, thanks so much for your help. Good to know that people still help people.

Later all and happy scripting.
Whiteink

hi whiteink,

I found a solution for you in this thread : http://bbs.applescript.net/viewtopic.php?id=16255
There is a scripting addition called “Extra Suite” you can use - I tried it - it’s working :slight_smile:

tell application "Adobe Illustrator"
activate
end tell
	tell application "System Events"
		tell process "Adobe Illustrator"
		tell menu bar 1
			tell menu bar item "Edit"
				tell menu "Edit"
					pick menu item "Find and Replace..."
					keystroke "boy"
					keystroke tab
					keystroke "girl"
				end tell
			end tell
		end tell
	tell process "Adobe Illustrator"
		set winPosition to position of window "Find and Replace"
	end tell
end tell
tell application "Extra Suites"
	ES move mouse {((item 1 of winPosition) + 465), ((item 2 of winPosition) + 45)}
	ES click mouse
end tell

Note: 465 and 45 are the x and y alues for my Illustrator’s search window (Illustrator CS, german). Yours will probably need other values …

This subject has also cropped up in one or two other discussions recently. You can download Extra Suites to try before you buy (at a modest cost). :slight_smile: