Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Script to switch between 2 resolutions

I'm fairly new to OSX (bought my first MAC last summer)


I find myself switching between 2 resolutions on my retina MacBook Pro.

I use 1920x1080 at work (professionaly, I run Windows8 in Fusion6 to manage the IT infrastructure) and 1280x720 at home (in the couch, with half an eye on the TV)


To switch between these 2 resolutions, I do the following steps

- CMD+SPACE

- type "display"

- ENTER

- use the mouse to switch to another resolution

- press OK


Wouldn't it be easyer if I had 1 program that:

- switches to 1920x1080 if the current resolution is 1280x720

- switches to 1280x720 if the current resolution is 1920x1080


A "shortcut" (or whatever it's called in OSX) on the desktop, or even with a key-combination would be great.


Any insights?

MacBook Pro (Retina, Mid 2012), OS X Mountain Lion (10.8.2), 16GB 256SSD w/ VMwareFusion

Posted on Sep 10, 2013 11:42 AM

Reply
20 replies

Oct 31, 2013 8:06 AM in response to Kingster21

Any idea why this is not working on my 13" rMBP running Mavericks 10.9? The error I'm getting is:


Result:

error "System Events got an error: Can’t get radio group 1 of group 1 of tab group 1 of window \"Built-in Retina Display\" of process \"System Preferences\". Invalid index." number -1719 from radio group 1 of group 1 of tab group 1 of window "Built-in Retina Display" of process "System Preferences"


Here's what the system preference pany looks like:

User uploaded file

Thanks!

Oct 31, 2013 8:51 AM in response to j.b.

I'm not an expert, but my guess it has something to to with this:


set index1 to 3 -- 1440 x 900 (Best for Retina)

set index2 to 5 -- 1920 x 1200 (More Space)


Your screenshot doesn't show "five" options, only four... the numbers I think you should try are:


set index1 to 2 -- 1440 x 900 (Best for Retina)

set index2 to 4 -- 1920 x 1200 (More Space)

Oct 31, 2013 11:03 AM in response to GeertCu

Thanks for the advise. It turns out the menu is slightly different for the 13" rMBP. I ended up writing two scripts that I can activate via launchbar (or quicksilver/alfred if they are your preference) to change the resolution. Here is the script to select the 1440x900 resolution:


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"

clickradio button "Display" of tab group 1

clickradio button "Scaled" of radio group 1 of tab group 1

click radio button 3 of radio group 1 of group 2 of tab group 1 of window "Built-in Retina Display" of application process "System Preferences" of application "System Events"

end tell

quit application "System Preferences"


Change 'radio button 3' to 'radio button 2' on the 7th line if you want to switch back to the default 'best for retina' resolution.


Hope this helps someone else!

Jul 23, 2014 5:37 AM in response to j.b.

Here is a script that works for my rMbp 13 with maverics:


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"

clickradio button "Display" of tab group 1

clickradio button "Scaled" of radio group 1 of tab group 1


tell radio group 1 of group 1 of tab group 1

set isRetinaOptimized to get value of radio button 4 of radio group 1 of group 2 of tab group 1 of window "Built-in Retina Display" of application process "System Preferences" of application "System Events"

end tell


if isRetinaOptimized then

click radio button 2 of radio group 1 of group 2 of tab group 1 of window "Built-in Retina Display" of application process "System Preferences" of application "System Events"

else

click radio button 4 of radio group 1 of group 2 of tab group 1 of window "Built-in Retina Display" of application process "System Preferences" of application "System Events"

end if



end tell

quit application "System Preferences"

Script to switch between 2 resolutions

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.