6

我正在尝试根据其文本使用 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并没有解决我认为应该的问题。我已经使用 Accessibility Inspector 来确认对象层次结构。我尝试在行上使用“UI 元素”来查看哪些元素是可访问的,但它没有返回任何有用的东西。所以我没主意!我错过了什么?

4

2 回答 2

6

在@markhunte 的提示下,我想出了如何使用UI Elementsand到达大纲中一行的文本get properties。事实证明,AXRow > AXCell > AXStaticTextAccessibility Inspector 显示的层次结构具有误导性。

每个文本都是通过 访问的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
于 2013-05-25T15:57:58.100 回答
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
于 2013-05-25T14:26:55.040 回答