This note illustrates how to adjust resolution using keyboard shorcut using built-in app automator
.
After setting up, I can use two actions:
- Switch to Highest resolution
- Switch to Default resolution
I'm new to apple script, so the rule is very simple.
Tested on macOS 10.15.4, with MBP 2017, 13-inch.
This is the screenshot of Display
option in System Preference > Displays.
Note:
The actions will require the access of Accessibility
.
e.g., If you are using Safari and want to switch the resolution, then Safari need to gain access of Accessibility
.
Otherwise the actions will failed.
The script below switch the resolution to the highest, if it's the highest currently, nothing will changed.
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 "Scaled" of tab group 1
click radio button 4 of radio group 1 of group 1 of tab group 1
end tell
quit application "System Preferences"
You can test/adjust it via built-in Script Editor.
The script below will switch the resolution to the default setting.
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"
tell tab group 1
click radio button "Display"
click radio button "Default for display"
end tell
end tell
quit application "System Preferences"
Once tested, you can add them into Automator.
- First open Automator and select Service type, and then select the action Run AppleScript. Set
Service receives
tono input
, and you can decide what application can use. - Then you can paste the code above into the script. You can then test it to see if it's working, it might first require the access of Accessibility.
- Save the workflow, then you will find the option with the name you just saved in System Preference > Keyboard > Shorcuts Tab > Services > General.
- Then you can set the shortcut and see if it worked.
Notice that the action will failed if it's not granted access.
A lot has changed in MacOS, I just figured this whole thing out for MacOS 14. Instructions here:
https://www.reddit.com/r/shortcuts/comments/163drpm/comment/koi9xhx/?utm_source=share&utm_medium=web2x&context=3