gpt4 book ai didi

macos - Applescript 获取元素

转载 作者:行者123 更新时间:2023-12-01 09:06:49 25 4
gpt4 key购买 nike

This SO answer在编写新 MacBook Retina 屏幕分辨率更改脚本时,我进一步指出了一点。我被困在这里:

enter image description here

我可以使用此脚本到达此 Pane :

tell application "System Preferences"
activate
set the current pane to pane id "com.apple.preference.displays"
reveal anchor "displaysDisplayTab" of current pane
get elements of current pane
tell application "System Events"

end tell
--get the name of every anchor of current pane
end tell

但是如果这个 Pane 内容如何知道如何选择位呢?例如,如何引用“缩放”单选按钮,并选择 5 种可能的分辨率之一?谢谢

最佳答案

我发现这段 AppleScript 显然可以检索窗口中可用的每个 UI 元素:

tell application "System Events"
tell process "Process Name"
set visible to true
return every UI element of front window
return name of every UI element of front window
end tell
end tell

(我自己还没有测试。找到了here。)

关于macos - Applescript 获取元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11708459/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com