MacOS – Changing Screen Resolution Using AppleScript

applescriptmacosresolutionterminal

How can I change change screen resolution using AppleScript? If AppleScript can't do it, what about Terminal?

I tried with examples at How to set screen resolution with a keyboard shortcut on Retina MBP?, but they don't work anymore. I'm on MacBookPro Retina.

This is how the script definitively should start:

    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"
          -- insert magic
        end tell
    end tell

Now I just need to click on "Scaled" and select different display resolutions, but I don't know how these buttons are "called".

Best Answer

Don't know if still works on current versions of OS X, but somebody wrote a command line tool to get and set resolutions a few years ago: https://github.com/jhford/screenresolution