Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access the text of a particular row of an outline control with AppleScript?

I'm trying to select a particular row of an outline using AppleScript, based on its text.

Here's what I'm considering (but doesn't work):

repeat with aRow in rows of outline 1 of scroll area 1 of splitter group 1 of window 1
    set t to text of cell of aRow
    if t starts with "some text" then select aRow
end repeat

The problem is that text of cell of aRow doesn't resolve to what I think it should. I've used the Accessibility Inspector to confirm the object hierarchy. I've tried using "UI Elements" on the row to see what elements are accessible, but it doesn't return anything useful. So I'm out of idea! What am I missing?

like image 312
ptrico Avatar asked May 25 '13 10:05

ptrico


2 Answers

With @markhunte's hint, I worked out how to reach the text of a row in the outline, using UI Elements and get properties. It turns out the AXRow > AXCell > AXStaticTexthierarchy displayed by the Accessibility Inspector was misleading.

The text of each is access through name of first UI Element of row (of outline...).

Here's the working code that does what I intended to achieve:

tell application "System Events"
    tell process "MyApp"

        repeat with aRow in row of outline 1 of scroll area 1 of splitter group 1 of window 1
            if name of first UI element of aRow starts with "Schedule" then select aRow
        end repeat

    end tel
end tell
like image 154
ptrico Avatar answered Oct 15 '22 20:10

ptrico


I think the thing you are missing is static text.

Here is an example of it with iTunes.

    tell application "System Events"
        tell process "iTunes"

            --  get properties of every static text in rows of outline 1 of scroll area 1 of splitter group 1 of window 1

            get properties of first static text in rows of outline 1 of scroll area 1 of splitter group 1 of window 1 whose description is "sources"
            get properties of first static text in rows of outline 1 of scroll area 1 of splitter group 1 of window 1 whose name is "LIBRARY"
            get properties of first static text in rows of outline 1 of scroll area 1 of splitter group 1 of window 1 whose value is "Spanish"


        end tell
    end tell
like image 22
markhunte Avatar answered Oct 15 '22 20:10

markhunte