如何使用 AppleScript 访问大纲控件特定行的文本?

ptr*_*ico 6 applescript nsoutlineview

我正在尝试根据其文本使用 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
Run Code Online (Sandbox Code Playgroud)

问题是这text of cell of aRow并没有解决我认为应该的问题。我使用了辅助功能检查器来确认对象层次结构。我试过在行上使用“UI Elements”来查看哪些元素是可访问的,但它没有返回任何有用的东西。所以我没主意了!我错过了什么?

ptr*_*ico 6

在@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
Run Code Online (Sandbox Code Playgroud)