Monday, October 23, 2017

#1 2010-05-25 12:12:49 pm

eclipse6248
Member
Registered: 2010-05-25
Posts: 3

Choose Display Profile

So I've been searching high and low for a way for users to select an appropriate monitor profile when they log into the system.  Based on some suggestions in another thread (I can't find the source at the moment on MacScripter, but I'll post it later on when and if I'm able to find it), but apparently Apple has removed the capability for Image Events to set a profile to a display.  The following example seemed to have worked under Leopard, but no longer works under Snow Leopard.

Applescript:

tell application "Image Events"
   launch
   tell displays to set {cnt, dName, sProfiles} to {count it, name, display profile}
   set allProfiles to name of profiles
end tell

repeat with i from 1 to cnt
   set newProfile to choose from list allProfiles with prompt "Choose profile for display " & i default items (name of item i of sProfiles)
   if newProfile is not false then
       set newProfile to item 1 of newProfile
       tell application "Image Events" to set profile of display i to profile newProfile
   end if
end repeat

I know I'm off when it comes to the "tell application "Image Events" to set profile of display i to profile newProfile"

The set function apparently no longer works because display is read only.  What I'm looking for is a workaround that will still allow me to choose a display profile and then apply it to each monitor connected.  Any help would be much appreciated.

Last edited by eclipse6248 (2010-05-25 12:25:54 pm)

Offline

 

#2 2010-05-25 01:04:02 pm

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Choose Display Profile

A quick search thought me that the display profile of a display is set with the application ColorSyncScripting. (Google search "display profile applescript", click first link.) Then I looked at the dictionary of Image Events, searched for the class profile and saw the location property. I coerced it in an alias and voila, the script is ready. Though it doesn't work for all profiles and some displays. E.g. the Black & White profile doesn't work for Samsung Syncmaster smile

Script:

Applescript:

tell application "Image Events"
   launch
   tell displays to set {cnt, dName, sProfiles} to {count it, name, display profile}
   set allProfiles to name of profiles
end tell

repeat with i from 1 to cnt
   set newProfile to choose from list allProfiles with prompt "Choose profile for display " & i default items (name of item i of sProfiles)
   if newProfile is not false then
       set newProfile to item 1 of newProfile
       --tell application "Image Events" to set display profile of display i to profile newProfile
       
       tell application "Image Events" to set profileAlias to location of profile newProfile
       set profileAlias to profileAlias as alias
       
       tell application "ColorSyncScripting"
           set display profile of display i to profileAlias
       end tell
   end if
end repeat

Hope it helps,
ief2

Last edited by ief2 (2010-05-25 01:06:20 pm)


One mans trash is another mans treasure

Offline

 

#3 2010-05-25 01:10:51 pm

Adam Bell
Administrator
From:: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4660

Re: Choose Display Profile

I think you might have to do it in the preference pane:

Applescript:


tell application "System Preferences"
   set current pane to pane id "com.apple.preference.displays"
   reveal (first anchor of current pane whose name is "displaysColorTab")
   -- do your stuff
   
end tell


iMac running OS X 10.12.6

Offline

 

#4 2010-05-25 02:54:34 pm

eclipse6248
Member
Registered: 2010-05-25
Posts: 3

Re: Choose Display Profile

ief2 wrote:

A quick search thought me that the display profile of a display is set with the application ColorSyncScripting.
ief2


Unfortunately, ColorSyncScripting no longer works under Snow Leopard.  You must be working with Tiger or Leopard.

Offline

 

#5 2010-05-25 02:56:06 pm

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Choose Display Profile

eclipse6248 wrote:

Unfortunately, ColorSyncScripting no longer works under Snow Leopard.  You must be working with Tiger or Leopard.


I work with Leopard indeed


One mans trash is another mans treasure

Offline

 

#6 2010-05-26 09:39:59 am

eclipse6248
Member
Registered: 2010-05-25
Posts: 3

Re: Choose Display Profile

I might just go with the systems preferences approach.  It may not be as clean, but it does essentially the same thing.

Offline

 

#7 2010-06-04 05:35:00 am

henin
Member
Registered: 2010-06-04
Posts: 3

Re: Choose Display Profile

Er, a bit new to all this, so what does Adam's "do your stuff" consist of?  How do you actually set a color profile once you're on the Color pane?

Oh, and how did you know what to do?  I get as far as "pane" by looking at the System Preferences dictionary but then I get stuck.

Thanks!

Last edited by henin (2010-06-04 12:39:03 pm)

Offline

 

#8 2010-06-04 02:27:57 pm

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Choose Display Profile

After you have displayed the pane, you can go on with GUI scripting. For this look at the "System Events" dictionary's Processes Suite. Here's an example of GUI scripting with iTunes:

Applescript:

tell application "System Events" to tell process "iTunes"
   activate
   -- activate Music Playlist
   tell window 1 to tell splitter group 1 to tell splitter group 1 to ¬
       tell scroll area 1 to tell outline 1 to select row 2
   
   
   tell window 1 -- main window
       click button 9 -- list
       delay 3
       click button 10 -- album covers
       delay 3
       click button 11 -- cover flow
   end tell
end tell

This script is tested with iTunes 9.1

Hope it helps,
ief2

PS: A good tool for GUI scripting is PreFab's UI Browser


One mans trash is another mans treasure

Offline

 

#9 2010-06-04 04:02:24 pm

henin
Member
Registered: 2010-06-04
Posts: 3

Re: Choose Display Profile

This seems to do the trick:

Applescript:

tell application "System Preferences"
   activate
   set current pane to pane id "com.apple.preference.displays"
   reveal (first anchor of current pane whose name is "displaysColorTab")
   tell application "System Events"
       tell process "System Preferences"
           select row 2 of table 1 of scroll area 1 of group 1 of tab group 1 of window "Color LCD"
       end tell
   end tell
   quit
end tell

Anything I'm missing?  Thanks!

Offline

 

#10 2010-10-04 06:29:53 pm

Gregory
Member
From:: Hong Kong
Registered: 2010-03-12
Posts: 1
Website

Re: Choose Display Profile

hello people.

I have a Spyder3 calibrator, and I change the display profile and brightness throughout the day as the ambient light changes. I wrote a script to set the display profile and brightness in the days of Leopard which worked until Snow Leopard happened and the script broke. but...

based on that script and what I've read here and in other places, I edited my script and it works again. here it is. I hope it is helpful.

(Note. I use Script Debugger and take advantage of its Libraries function; i.e., I have 5 scripts, one for each ambient level, all of them single-line scripts calling the configureTheDisplay() function embedded via the Libraries function. You could probably do something similar in Script Editor by using the Load Script function.)

Applescript:


-- Note 1. theProfilesName is the name of the profile as seen in the Displays pref panel, not its alias.
-- Note 2. brightnessValue is a Number. do not wrap its value in quotation marks.
configureTheDisplay("Spyder3Pro Very Low", 13 / 64)

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

 
 
I use the following script to get the Display Brightness value after I've done a calibration, which I then plug back into the script above.

Applescript:


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"


Filed under: Display, profile

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)