单击未知的 UI 元素



我找到了一个UI元素,它实际上是一个按钮,但显示为AXUnknown。

该窗口显示在以下链接中:http://s8.postimage.org/p7123rw85/screen.png

使用命令单击不起作用,所以我想我会尝试一些不同的东西。

我尝试过的:

从这个元素中,我可以通过执行以下命令来获取元素的位置: get value of attribute "AXPosition"

然后,我可以使用从中获得的坐标,通过使用click at命令单击未知的UI元素。

更新

我现在也尝试使用 perform action "AXPress" of 命令。

tell application "System Events"
    tell process "SomeProcess"
        if (exists window "SomeWindow") then
            perform action "AXPress" of UI element 3 of UI element 6 of window "SomeWindow"
        end if
    end tell
end tell

这没有任何作用,我没主意了。有没有人对这个问题有任何经验,或者知道这是否根本无法实现?

如果正常的 gui 脚本技术不起作用,那么作为最后的手段,您可以尝试击键。首先,您需要设置系统首选项以启用此技术。在此处检查窗口底部的"所有控件"按钮...系统偏好设置 ->键盘 ->键盘快捷键选项卡。启用此功能后,您可以使用选项卡按钮循环浏览窗口的各种 UI 元素。当您按 Tab 键转到按钮后,请按空格键。因此,计算您需要按下才能到达按钮的选项卡数量,然后这样的事情可能会起作用。

set numberOfTabs to 3
set shortDelay to 0.2
tell application "Whatever" to activate
delay shortDelay
tell application "System Events"
    repeat numberOfTabs times
        keystroke tab
        delay shortDelay
    end repeat
    keystroke space
end tell

请注意,这不是很可靠,因为选项卡的数量可能并不总是一致的。你必须检查一下。

最新更新