使用AppleScript更改屏幕分辨率 [英] change screen resolution with AppleScript

查看:332
本文介绍了使用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的一部分.无线电组是tab 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更改屏幕分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆