Need help with an applescript to click in the toolbar

Hello,
I try to write a script to click in a toolbar. UIElementinspector looks like this:

<AXApplication: “iDatabase”>
<AXWindow: “iDatabase”>


Attributes:
AXRole: “AXImage”
AXRoleDescription: “image”
AXHelp: “(null)”
AXEnabled: “1”
AXFocused: “0”
AXParent: “”
AXWindow: “<AXWindow: “iDatabase”>”
AXTopLevelUIElement: “<AXWindow: “iDatabase”>”
AXPosition: “x=243 y=143”
AXSize: “w=165 h=40”
AXDescription: “”

This is the output of Applescript Editor:

{{{image 1 of group 1 of toolbar 1 of window "iDatabase" of application process "iDatabase" of application "System Events", image 2 of group 1 of toolbar 1 of window "iDatabase" of application process "iDatabase" of application "System Events", image 3 of group 1 of toolbar 1 of window "iDatabase" of application process "iDatabase" of application "System Events"}, {}, {image 1 of group 3 of toolbar 1 of window "iDatabase" of application process "iDatabase" of application "System Events"}}}

Then I try this code:

tell application "System Events"
	tell process "iDatabase"
		perform action "AXPress" of image 1 of group 1 of toolbar 1 of window 1
	end tell
end tell

The result is missing value

Help would be appreciated.

Fred

May you try to add the instruction :
activate application “iDatabase”
just before telling to System Events ?

Yvan KOENIG (VALLAURIS, France) mardi 17 juin 2014 17:10:54

The image doesn’t understand the action.

I was able to do the trick with this code :

activate application "iDatabase"
tell application "System Events"
	tell process "iDatabase"
		set imagePosition to position of image 1 of group 1 of toolbar 1 of window 1
	end tell
end tell
tell application "ASObjC Runner"
	click button once at imagePosition
end tell

ASObjC Runner is available for free at :
http://www.macosxautomation.com/applescript/apps/runner.html

If you don’t want to use ASObjC Runner, you may use this alternate code
which requires the Unix command Cliclik available for free at :
http://www.bluem.net/en/mac/cliclick/

activate application "iDatabase"
tell application "System Events"
	tell process "iDatabase"
		set {xPos, yPos} to position of image 1 of group 1 of toolbar 1 of window 1
	end tell
end tell
tell me to do shell script "/usr/bin/cliclick c:" & xPos & "," & yPos

Hi,

the action AXPress should be listed in the UIElementinspector window,
but the target UI element AXImage normally doesn’t respond to mouse clicks (unlike a button)

Thanks Yvan,
Your code with cliclick worked! It was the one i tried.

Fred