GeertCu

Q: 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 12:41 PM

Close

Q: Script to switch between 2 resolutions

  • All replies
  • Helpful answers

Previous Page 2
  • by j.b.,

    j.b. j.b. Oct 31, 2013 8:06 AM in response to Kingster21
    Level 1 (65 points)
    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:

    Screenshot 2013-10-31 08.04.26.png

    Thanks!

  • by GeertCu,

    GeertCu GeertCu Oct 31, 2013 8:51 AM in response to j.b.
    Level 1 (0 points)
    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)

  • by j.b.,

    j.b. j.b. Oct 31, 2013 11:03 AM in response to GeertCu
    Level 1 (65 points)
    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"

    click radio button "Display" of tab group 1

    click radio 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!

  • by joakimbr,

    joakimbr joakimbr Jul 23, 2014 5:37 AM in response to j.b.
    Level 1 (0 points)
    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"

    click radio button "Display" of tab group 1

    click radio 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"

  • by ivanreyes,

    ivanreyes ivanreyes Oct 22, 2014 4:45 PM in response to Kingster21
    Level 1 (0 points)
    Oct 22, 2014 4:45 PM in response to Kingster21

    Kingster,

     

    Did the terminology or UI change from Mavericks to Yosemite ?

     

    I can't seem to find the error.

     

    Screen Shot 2014-10-22 at 4.41.41 PM.png

     

    Screen Shot 2014-10-22 at 4.41.57 PM.png

     

    thanks

Previous Page 2