AlexanderN
AlexanderN

Reputation: 2670

Clicking on an unknown UI element

I have located an UI element which actually is a button, but shows up as AXUnknown.

The window is show in the following link: http://s8.postimage.org/p7123rw85/screen.png

Using the command click doesn't work, so I thought I'd try something different.

What I have tried:

From this element I can get the position of the element by doing a: get value of attribute "AXPosition"

And then I could use the coordinates that I get from this to click on the unknown UI element by using the click atcommand.

Update

I have now also tried using the perform action "AXPress" of command also.

tell application "System Events"

    tell process "SomeProcess"

        if (exists window "SomeWindow") then

            perform action "AXPress" of UI element 3 of UI element 6 of window "SomeWindow"

        end if
    end tell
end tell

This does nothing and Im running out of ideas. Does anyone have any experience with this issue or know if this simply isn't possible to accomplish?

Upvotes: 0

Views: 2119

Answers (1)

regulus6633
regulus6633

Reputation: 19030

If normal gui scripting techniques aren't working then as a last resort you may try keystrokes. First you need to set a system preference to enable this technique. Check the "all controls" button at the bottom of the window here... system preferences -> keyboard -> keyboard shortcuts tab. With this enabled you can use the tab button to cycle through the various ui elements of a window. When you have tabbed to the button then press the space bar. So count the number of tabs you need to press to get to the button then something like this might work.

set numberOfTabs to 3
set shortDelay to 0.2

tell application "Whatever" to activate
delay shortDelay
tell application "System Events"
    repeat numberOfTabs times
        keystroke tab
        delay shortDelay
    end repeat
    keystroke space
end tell

Note that this isn't very reliable as the number of tabs may not always be consistent. You'll have to check that.

Upvotes: 1

Related Questions