本文介绍了使用 AppleScript 更改屏幕分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试单击系统首选项"的显示"面板中的单选按钮,即更改屏幕分辨率.这是我用来识别单选按钮的代码:

I am trying to click at radio buttons in Displays panel of System Prefernces, namely to change Screen resolution. This is the code I use to identify radio buttons:

tell application "System Preferences"
    activate
    reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
end tell
tell application "System Events"
    tell application process "System Preferences"
        set frontmost to true
        get every radio button of window 0

        --click button 1 of window 0 of application process "System Preferences" of application "System Events"

        --click radio button "Scaled" of radio group of window "com.apple.preference.displays"
    end tell
end tell

返回的单选按钮没有.根据我所见,窗口的单选按钮为零.这导致了一个结论,即单选按钮是子窗口的一部分,即显示子窗口而不是主窗口.如何导航到此子窗口"并单击单选按钮?

The radio buttons returned are none. Based on what I see, window has zero radio buttons. This leads to a conclusion that radio buttons are part of sub window, namely the Displays subwindow and not the main window. How can I navigate to this "subwindow" and click radiobuttons?

推荐答案

单选按钮是 radio group 的一部分.无线电组是标签组的一部分.

The radio buttons are part of the radio group. The radio group is part of the tab group.

脚本如下:

tell application "System Preferences"
    activate
    reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
end tell
tell application "System Events"
    tell application process "System Preferences"
        set frontmost to true
        tell tab group 1 of window 1
            click radio button 2 of radio group 1 -- "Scaled"
            select row 2 of table 1 of scroll area 1 -- select the second row in the table to change the resolution of the monitor
        end tell
    end tell
end tell

这篇关于使用 AppleScript 更改屏幕分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 13:59
查看更多