我正在尝试使用AppleScript根据文本选择轮廓的特定行。
这是我正在考虑的(但不起作用):
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
问题是text of cell of aRow
无法解决我认为应该解决的问题。
我使用了辅助功能检查器来确认对象层次结构。我已经尝试在行上使用“UI元素”来查看哪些元素是可访问的,但它不会返回任何有用的内容。所以我不明白!我错过了什么?
答案 0 :(得分:4)
通过@ markhunte的提示,我找到了如何使用UI Elements
和get properties
来查看大纲中行的文本。事实证明,辅助功能检查器显示的AXRow > AXCell > AXStaticText
层次结构具有误导性。
每个文本都可以通过name of first UI Element of row (of outline...)
进行访问。
这是我打算实现的工作代码:
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
答案 1 :(得分:1)
我认为您缺少的是静态文字。
这是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