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?
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 > AXStaticText
hierarchy 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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With