通过 AppleScript 在系统设置的外观部分切换“显示滚动条”单选按钮

问题描述 投票:0回答:1

我需要编写 AppleScript,设置一些值以在新的系统设置 UI 中显示滚动条。

Screenshot of what I want to change in result

这是我想出的代码

tell application "System Settings"
    activate
    set current pane to pane id "com.apple.Appearance-Settings.extension"
end tell

delay 0.1

tell application "System Events" to tell application process "System Settings"
    -- ...
end tell
macos applescript accessibility appearance
1个回答
0
投票

我发现了 Accessibility Inspector 应用程序,您可以在其中查看任何应用程序中元素的层次结构。在它的帮助下,我编写了工作脚本:

tell application "System Settings"
    activate
    set current pane to pane id "com.apple.Appearance-Settings.extension"
end tell

delay 0.1

tell application "System Events" to tell application process "System Settings"
    set frontmost to true
    tell window 1
        tell group 1
            tell splitter group 1
                tell group 2
                    tell group 1
                        tell scroll area 1
                            tell group 2
                                tell radio group 1
                                    set targetUIElement to a reference to radio button 1
                                    if targetUIElement exists then
                                        click targetUIElement
                                    end if
                                end tell
                            end tell
                        end tell
                    end tell
                end tell
            end tell
        end tell
        tell button 1 to click
    end tell
end tell
© www.soinside.com 2019 - 2024. All rights reserved.