如何在applescript中获取选定的ui元素?

时间:2019-03-16 14:42:20

标签: applescript

我正在尝试为没有字典的应用程序创建脚本。如何获取所选列表项?

我需要这样的东西

tell application "System Events" tell process "process" get selected item of list 1 of splitter group 1 of window 1 end tell end tell

_

choose from list list 1...失败,出现1700错误(无法转换为字符串)

1 个答案:

答案 0 :(得分:0)

不幸的是,这些特定元素(它们是静态文本UI元素)中的每个元素的selected属性似乎都无法访问。 执行以下操作:

activate application "SongOfGod_1_2"

--(this line above is just to make sure
-- we don't miss anything by not having the app frontmost;
--for many commands it is unnecessary)

tell application "System Events"
    tell process "SongOfGod"
        properties of static text 2 of list 1 of splitter group 1 of group 1 of splitter group 1 of window 1
    end tell
end tell

返回:

{class:static text, minimum value:missing value, orientation:missing value, position:{595, 259}, accessibility description:"2. And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.", role description:"text", focused:false, title:missing value, size:{1605, 18}, help:missing value, entire contents:{}, enabled:true, maximum value:missing value, role:"AXStaticText", value:missing value, subrole:missing value, selected:missing value, name:missing value, description:"2. And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters."}

如果您滚动到该位置,您会注意到selected属性返回missing value,这意味着您无法确定它是否被选中。我还尝试了focused,但没有用。 clickselect也不起作用。尝试获取包含列表的selected属性也不起作用。

很抱歉,您显然无法从该应用程序中获得想要的东西。