Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Scripting Display Preferences

I often need to change the color profile on my secondary display, so how would you write an AppleScript to open System Preferences, go to the Display preferences on the secondary display and change the color profile?

Mac OS X (10.6.4)

Posted on Aug 8, 2010 1:42 PM

Reply
3 replies

Aug 8, 2010 10:12 PM in response to Arzati

The following code will do it use GUI scripting. It actually opens up system preferences clicks on what you want and then exits. Note that the delays are to give time for windows and such to open and can be shortened from 1sec as necessary for your system. Also the heart of this script is in the line where it "select row 3 of..." you should change row 3 to the appropriate row in your system pref screen box.

Hope this helps.

tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.displays"
end tell
tell application "System Events"
tell process "System Preferences"
click radio button "Color" of tab group 1 of window "Color LCD"
delay 1
select row 3 of table of scroll area of group of tab group 1 of window "Color LCD"
end tell
end tell
delay 1
tell application "System Preferences"
quit
end tell


This can be easily edited into a toggle switch using if else statements or ask for your input to which display to go to.

Sep 16, 2010 1:30 AM in response to Arzati

Arzati,

based on experience and Taylor's reply, I came up with this script. it's an update of one I used before Snow Leopard killed the 'set display profile' command.

I use the Spyder3Pro calibrator and updated last night to Spyder3Elite with automatic brightness adjustment. I maintain profiles for each ambient light setting; *Very Low* to *Very High*. After each calibration, I run a script to get the display's brightness level and then paste it into the script that switches the Display Profile and adjusts the Brightness.

hope this helps. cheers.

<hr />

configureTheDisplay("Spyder3Pro Very High", 61/64)

-- subroutines

to configureTheDisplay( theProfilesName, brightnessValue)
tell application "System Events"
*if not* UI elements enabled then
DisplayAssistanceInstructions() *of me*
return
*end if*

openDisplaysPrefPane() *of me*
tell process "System Preferences"
-- set the brightness
-- make sure the Display panel is on.
click radio button "Display" of tab group 1 of window 1
set slider 1's value of group 2 of tab group 1 of window 1 to brightnessValue

-- set the ColorSync Profile
click radio button "Color" of tab group 1 of window 1
select ( first row of table of scroll area of group of tab group 1 of window 1 *where its first* static text's name is theProfilesName)
*end tell*
quitPrefs() *of me*
*end tell*
return
end configureTheDisplay

to DisplayAssistanceInstructions()
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
*display alert* "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
*end tell*
end DisplayAssistanceInstructions

to openDisplaysPrefPane()
tell application "System Preferences"
set current pane to pane "Displays"
*end tell*
end openDisplaysPrefPane

to quitPrefs()
quit application "System Preferences"
end quitPrefs

<hr />

the script to get the current brightness setting (without colour formatting):

tell application "System Preferences" to ¬
set current pane to pane "Displays"

tell application "System Events"
tell tab group 1 of window 1 of process "System Preferences"
click radio button "Display"
tell slider 1 of group 2
set v_true to value
end tell
end tell
end tell
quit application "System Preferences"

set v to v_true * 64 as integer
if v mod 4 = 0 then
set v to ((v / 4 as integer) & "/16") as string
else if v mod 2 = 0 then
set v to ((v / 2 as integer) & "/32") as string
else
set v to (v & "/64") as string
end if
display alert "Current Display Brightness: " & v & " (" & v_true & ")" buttons "OK"

Scripting Display Preferences

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.