Skip to main content
added fix for macOS Sequoia
Source Link
Zade
  • 181
  • 1
  • 4

Broken again with macOS Sequoia, because the UI element is now:

UI element 1 of group 1 of scroll area 2 of group 1 of list 2 of splitter group 1 of list 1 of window "Displays"

My shortcut no longer toggles between resolutions. Instead I have a shortcut for each resolution, so I posted my latest script (working on macOS 15.1.1) in a new answer below (https://apple.stackexchange.com/a/477031/27373)


Proposed Fix for Zade's change for the Browser UI System Preferences in 13.0.1, the Shortcut didn't work anymore for me in Ventura 13.2 because of an error around the value of attribute "AXAttributedDescription" part

Proposed Fix for Zade's change for the Browser UI System Preferences in 13.0.1, the Shortcut didn't work anymore for me in Ventura 13.2 because of an error around the value of attribute "AXAttributedDescription" part

Broken again with macOS Sequoia, because the UI element is now:

UI element 1 of group 1 of scroll area 2 of group 1 of list 2 of splitter group 1 of list 1 of window "Displays"

My shortcut no longer toggles between resolutions. Instead I have a shortcut for each resolution, so I posted my latest script (working on macOS 15.1.1) in a new answer below (https://apple.stackexchange.com/a/477031/27373)


Proposed Fix for Zade's change for the Browser UI System Preferences in 13.0.1, the Shortcut didn't work anymore for me in Ventura 13.2 because of an error around the value of attribute "AXAttributedDescription" part

Proposed Fix for Zade's change for the Browser UI System Preferences in 13.0.1, the Shortcut didn't work anymore for me in Ventura 13.2 because of an error around the value of attribute "AXAttributedDescription" part

What I use in Ventura 13.2 now:

do shell script "open x-apple.systempreferences:com.apple.preference.displays"
tell application "System Events"
    tell application process "System Settings"
        repeat until (exists UI element 1 of group 1 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window 1)
            delay 0.1
        end repeat
        tell window 1 #"Displays"
            set displayOptions to UI element 1 of group 1 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1
            set StandardRes to button 4 of displayOptions
            set MoreSpaceRes to button 5 of displayOptions
            
            if focused of StandardRes is false then
                click StandardRes
            else
                click MoreSpaceRes
            end if
        end tell
    end tell
end tell
quit application "System Settings"

This switches between the Standard resolution and the "More Space" one ("Mehr Fläche" in German) and should be system language independent.


Fix for wch1zpink's answer on macOS 13.0.1, thanks to the UI Browser app:

Fix for wch1zpink's answer on macOS 13.0.1, thanks to the UI Browser app:

Proposed Fix for Zade's change for the Browser UI System Preferences in 13.0.1, the Shortcut didn't work anymore for me in Ventura 13.2 because of an error around the value of attribute "AXAttributedDescription" part

What I use in Ventura 13.2 now:

do shell script "open x-apple.systempreferences:com.apple.preference.displays"
tell application "System Events"
    tell application process "System Settings"
        repeat until (exists UI element 1 of group 1 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window 1)
            delay 0.1
        end repeat
        tell window 1 #"Displays"
            set displayOptions to UI element 1 of group 1 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1
            set StandardRes to button 4 of displayOptions
            set MoreSpaceRes to button 5 of displayOptions
            
            if focused of StandardRes is false then
                click StandardRes
            else
                click MoreSpaceRes
            end if
        end tell
    end tell
end tell
quit application "System Settings"

This switches between the Standard resolution and the "More Space" one ("Mehr Fläche" in German) and should be system language independent.


Fix for wch1zpink's answer on macOS 13.0.1, thanks to the UI Browser app:

deleted 8 characters in body; edited body
Source Link
Zade
  • 181
  • 1
  • 4
do shell script "open x-apple.systempreferences:com.apple.Displays-Settingspreference.extension"displays"
tell application "System Events"
    tell application process "System Settings"
        repeat until (exists UI element 1 of group 1 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays")
            delay 0.1
        end repeat
        tell window "Displays"
            set displayOptions to UI element 1 of group 1 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1
            set theButton to (first button of displayOptions whose value of attribute "AXAttributedDescription" contains "Selected")
            if help of theButton is "2560 × 1440" then
                click button 1 of displayOptions
            else
                click button 3 of displayOptions
            end if
        end tell
    end tell
end tell
quit application "System Settings"

Fix for wch1zpink's answer on macOS 1012.150.41:

tell application "System Preferences"
    reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
end tell
tell application "System Events" 
 to   tell application process "System Preferences" to tell 
 window "Built-in Retina Display"
    set isScaled torepeat valueuntil of(exists radio button "Scaled" of tabradio group 1
   of ifgroup isScaled1 =of 0window then"Displays")
        click radio button "Scaled" of tab groupdelay 0.1
        clickend radiorepeat
 button 1 of radio group 1 of grouptell 1window of"Displays"
 tab group 1
    else
     set isScaled to value clickof radio button "Default for display""Scaled" of tabradio group 1
    end if
end tell
quit applicationof "Systemgroup Preferences"1

Fix for wch1zpink's answer on macOS 12.0.1:

tell application "System Preferences"
    reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
endif tell
tellisScaled application= "System0 Events"then
    tell application process "System Preferences"
        repeat until (existsclick radio button "Scaled" of radio group 1 of group 1 
 of window "Displays")
            delay 0.1
click button 1 of UI element 3 of endgroup repeat1
        tell window "Displays"  else
            set isScaled to value ofclick radio button "Scaled""Default for display" of radio group 1 of group 1
            end if 
 isScaled = 0 then
    end tell
    end tell
end tell
quit application "System Preferences"

Fix on macOS 10.15.4:

tell application click"System radioPreferences"
 button "Scaled" of radioreveal groupanchor 1"displaysDisplayTab" of grouppane 1"com.apple.preference.displays"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display"
    set clickisScaled buttonto 1value of UIradio elementbutton 3"Scaled" of tab group 1
    if isScaled = 0 then
       else
 click radio button "Scaled" of tab group 1
        click radio button "Default for display"1 of radio group 1 of group 1
  of tab group 1
    else
     end if
  click radio button "Default for display" endof telltab group 1
    end tellif
end tell
quit application "System Preferences"
do shell script "open x-apple.systempreferences:com.apple.Displays-Settings.extension"
tell application "System Events"
    tell application process "System Settings"
        repeat until (exists UI element 1 of group 1 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays")
            delay 0.1
        end repeat
        tell window "Displays"
            set displayOptions to UI element 1 of group 1 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1
            set theButton to (first button of displayOptions whose value of attribute "AXAttributedDescription" contains "Selected")
            if help of theButton is "2560 × 1440" then
                click button 1 of displayOptions
            else
                click button 3 of displayOptions
            end if
        end tell
    end tell
end tell
quit application "System Settings"

Fix for wch1zpink's answer on macOS 10.15.4:

tell application "System Preferences"
    reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display"
    set isScaled to value of radio button "Scaled" of tab group 1
    if isScaled = 0 then
        click radio button "Scaled" of tab group 1
        click radio button 1 of radio group 1 of group 1 of tab group 1
    else
        click radio button "Default for display" of tab group 1
    end if
end tell
quit application "System Preferences"

Fix for wch1zpink's answer on macOS 12.0.1:

tell application "System Preferences"
    reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
end tell
tell application "System Events"
    tell application process "System Preferences"
        repeat until (exists radio button "Scaled" of radio group 1 of group 1 of window "Displays")
            delay 0.1
        end repeat
        tell window "Displays"
            set isScaled to value of radio button "Scaled" of radio group 1 of group 1
            if isScaled = 0 then
                click radio button "Scaled" of radio group 1 of group 1
                click button 1 of UI element 3 of group 1
            else
                click radio button "Default for display" of radio group 1 of group 1
             end if
        end tell
    end tell
end tell
quit application "System Preferences"
do shell script "open x-apple.systempreferences:com.apple.preference.displays"
tell application "System Events"
    tell application process "System Settings"
        repeat until (exists UI element 1 of group 1 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays")
            delay 0.1
        end repeat
        tell window "Displays"
            set displayOptions to UI element 1 of group 1 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1
            set theButton to (first button of displayOptions whose value of attribute "AXAttributedDescription" contains "Selected")
            if help of theButton is "2560 × 1440" then
                click button 1 of displayOptions
            else
                click button 3 of displayOptions
            end if
        end tell
    end tell
end tell
quit application "System Settings"

Fix on macOS 12.0.1:

tell application "System Preferences"
    reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
end tell
tell application "System Events" 
    tell application process "System Preferences" 
        repeat until (exists radio button "Scaled" of radio group 1 of group 1 of window "Displays")
            delay 0.1
        end repeat
        tell window "Displays"
            set isScaled to value of radio button "Scaled" of radio group 1 of group 1
            if isScaled = 0 then
                click radio button "Scaled" of radio group 1 of group 1 
                click button 1 of UI element 3 of group 1
            else
                click radio button "Default for display" of radio group 1 of group 1
            end if 
        end tell
    end tell
end tell
quit application "System Preferences"

Fix on macOS 10.15.4:

tell application "System Preferences"
    reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display"
    set isScaled to value of radio button "Scaled" of tab group 1
    if isScaled = 0 then
        click radio button "Scaled" of tab group 1
        click radio button 1 of radio group 1 of group 1 of tab group 1
    else
        click radio button "Default for display" of tab group 1
    end if
end tell
quit application "System Preferences"
added solution for macOS Ventura
Source Link
Zade
  • 181
  • 1
  • 4
Loading
added 187 characters in body
Source Link
Zade
  • 181
  • 1
  • 4
Loading
updated solution for macOS Monterey
Source Link
Zade
  • 181
  • 1
  • 4
Loading
Source Link
Zade
  • 181
  • 1
  • 4
Loading