Skip to content

Instantly share code, notes, and snippets.

@mvaneijgen
Created March 9, 2015 14:10
Show Gist options
  • Save mvaneijgen/2f48f859ca07d2e75b3a to your computer and use it in GitHub Desktop.
Save mvaneijgen/2f48f859ca07d2e75b3a to your computer and use it in GitHub Desktop.
Change screen resolution using Applescript works on 10.10 non-rentia macbook
-- Launch "System Preferences", open the "Displays" options and change to the "Display" tab
tell application "System Preferences"
activate
set the current pane to pane id "com.apple.preference.displays"
reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
end tell
local indexToUse
-- Now lets make the necessary changes
tell application "System Events"
tell tab group 1 of window "SyncMaster" of application process "System Preferences" of application "System Events"
tell radio group 1
if (value of radio button "Scaled") = 0 then
-- Click the "Scaled" radio button
click radio button "Scaled"
tell table 1 of scroll area 1 of tab group 1 of window "SyncMaster" of application process "System Preferences" of application "System Events"
select row 4
end tell
else
click radio button "Default for display"
end if
end tell
end tell
end tell
-- Quit "System Preferences"
quit application "System Preferences"
@jakehilborn
Copy link

@TheCatCoder I wrote a command line tool, displayplacer, that lets you programmatically change screen resolutions - including the hidden scaled ones.

@yomybaby
Copy link

yomybaby commented Feb 22, 2020

Thank you for sharing. I works then I expected. ๐Ÿ‘
I add delay 1 before if (value of radio button "Scaled") = 0 then because waiting for Scaled radio button to appear.

For the another language and monitor, you have to change monitor name and button names.
For example, Korean, Scaled to ํ•ด์ƒ๋„ ์กฐ์ ˆ, Default for display to ๋””์Šคํ”Œ๋ ˆ์ด์— ์ตœ์ ํ™”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment