Cannot click a button: why?

I'm having troubles to click two buttons in the Java app CafeTran Espresso:


And:

I have tried to:

  • Find the images of the buttons
  • Click at absolute postions
  • Simulate a Return

All to no avail ...

Then I tried an AppleScript:

tell application "System Events"
	click button 1 of window "Select an Option" of application process "CafeTran" of application "System Events"
	delay 0.5
	click button 1 of window "Message" of application process "CafeTran" of application "System Events"
end tell

This works in the AppleScript editor and when I run the embedding action in the KM macro. However, it doesn't work when I run the whole macro:


Am I doing something wrong here? Thanks for your help!
Hans

Solved it via AppleScript:

tell application "System Events"
	tell process "CafeTran"
		set frontmost to true
		key code 119 using {control down, option down} -- control-option-end
	end tell
	delay 0.5
	click button 1 of window "Select an Option" of application process "CafeTran" of application "System Events"
	delay 0.5
	click button 1 of window "Message" of application process "CafeTran" of application "System Events"
end tell

Always nice to find our own solution! Just an FYI, you ca simplify your AppleScript. Right now you have superfluous tell commands. See my example below.

tell application "System Events" to tell application process "CafeTran"
	set frontmost to true
	key code 119 using {control down, option down} -- control-option-end
	delay 0.5
	click button 1 of window "Select an Option"
	delay 0.5
	click button 1 of window "Message"
end tell
1 Like