Automate Screen Resolution Change

Please let me know how to automate a change to my Mac’s screen resolution. I’ve searched all over and everything is out of date. There has to be a simple Applescript or command to do this right?

Not sure where you searched, but look here:

http://bbs.applescript.net/viewtopic.php?id=14445
and here:
http://bbs.applescript.net/viewtopic.php?id=14539
and here:
http://bbs.applescript.net/viewtopic.php?id=15425

Basically, finding out what the screen resolution is, or changing it is best done as a shell script from AppleScript because GUI scripting the Display Preference Panel is a pain.

Here is a script you might try:


tell application "System Preferences" to activate
delay 1
tell application "System Events"
	tell process "System Preferences"
		click menu item "Displays" of menu "View" of menu bar 1
		click radio button "Display" of tab group 1 of window "[name in title bar]"
		set res to value of text field 1 of row 10 of table 1 of scroll area 1 of group 1 of tab group 1 of window "[name in title bar]"
		set theRows to every row of table 1 of scroll area 1 of group 1 of tab group 1 of window "[name in title bar]"
		delay 1
		set theOutputs to {} as list
		repeat with aRow in theRows
			if (value of text field 1 of aRow as text) is equal to "[resolution of your choice]" then
				set selected of aRow to true
				exit repeat
			end if
		end repeat
	end tell
end tell

where “[name in title bar]” is the name that appears in the title bar when you click System Preferences | Displays
“[resolution of your choice” is your desired screen resolution e.g. “1600 x 1000”

You may need to adjust the delay values depending on the speed of your computer.

Model: Mac Pro 8-core
Browser: Opera/9.25 (Macintosh; Intel Mac OS X; U; en)
Operating System: Mac OS X (10.5)