tell application "System Preferences"
reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
end tell
tell application "System Events"
tell application process "System Preferences"
repeat until (exists radio button "Scaled" of radio group 1 of group 1 of window "Displays")
delay 0.1
end repeat
tell window "Displays"
set isScaled to value of radio button "Scaled" of radio group 1 of group 1
if isScaled = 0 then
click radio button "Scaled" of radio group 1 of group 1
click button 1 of UI element 3 of group 1
else
click radio button "Default for display" of radio group 1 of group 1
end if
end tell
end tell
end tell
quit application "System Preferences"