javascriptjsxphotoshopphotoshop-script

I need a script to check the Color Setting


I need a script to check Color Setting and change to another one or use it before I work with my pictures

Color Settings

I found a listener script can load a CSF file but don't know how to check the Color Settings.

var idcolorSettings = stringIDToTypeID( "colorSettings" );

if (idcolorSettings == "Untitled1.CSF") //something wrong here
{
var idsetd = charIDToTypeID( "setd" );
    var desc38 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
       var ref13 = new ActionReference();
        var idPrpr = charIDToTypeID( "Prpr" );
        var idcolorSettings = stringIDToTypeID( "colorSettings" );
        ref13.putProperty( idPrpr, idcolorSettings );
        var idcapp = charIDToTypeID( "capp" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idcapp, idOrdn, idTrgt );
    desc38.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc39 = new ActionDescriptor();
        var idUsng = charIDToTypeID( "Usng" );
        desc39.putPath( idUsng, new File( ".../AppData/Roaming/Adobe/Color/Settings/Untitled2.CSF" ) );
    var idcolorSettings = stringIDToTypeID( "colorSettings" );
    desc38.putObject( idT, idcolorSettings, desc39 );
executeAction( idsetd, desc38, DialogModes.NO );
load
}
else {
//will change another CSF file
}

Please help me to fix it.


Solution

  • At the risk that I've mis-understood your question here goes: Change the USERNAME or the absolute path to fit your needs. Apply your script to the Script Events Manager to Open a New Document - so you won't have to run the script each time you open a script.

    // Switch off any dialog boxes
    displayDialogs = DialogModes.ERROR; // OFF
    
    load_colour_settings();
    
    // Set Display Dialogs back to normal
    displayDialogs = DialogModes.ALL; // NORMAL
    
    
    function load_colour_settings()
    {
      
      if (app.activeDocument.name.indexOf ("A") != -1)
      { 
        // load Untitled1.CSF 
        var colourFile = "C:\\Users\\USERNAME\\AppData\\Roaming\\Adobe\\Color\\Settings\\Untitled1.CSF";
      }
      else if (app.activeDocument.name.indexOf ("2") != -1) 
      { 
      // load Untitled2.CSF 
        var colourFile = "C:\\Users\\USERNAME\\AppData\\Roaming\\Adobe\\Color\\Settings\\Untitled2.CSF";
      }
      // None of the above? Don't do anything
      else return;
    
      // alert(colourFile);
      var idsetd = charIDToTypeID( "setd" );
      var desc38 = new ActionDescriptor();
      var idnull = charIDToTypeID( "null" );
      var ref13 = new ActionReference();
      var idPrpr = charIDToTypeID( "Prpr" );
      var idcolorSettings = stringIDToTypeID( "colorSettings" );
      ref13.putProperty( idPrpr, idcolorSettings );
      var idcapp = charIDToTypeID( "capp" );
      var idOrdn = charIDToTypeID( "Ordn" );
      var idTrgt = charIDToTypeID( "Trgt" );
      ref13.putEnumerated( idcapp, idOrdn, idTrgt );
      desc38.putReference( idnull, ref13 );
      var idT = charIDToTypeID( "T   " );
      var desc39 = new ActionDescriptor();
      var idUsng = charIDToTypeID( "Usng" );
      desc39.putPath( idUsng, new File( colourFile ) );
      var idcolorSettings = stringIDToTypeID( "colorSettings" );
      desc38.putObject( idT, idcolorSettings, desc39 );
      executeAction( idsetd, desc38, DialogModes.NO );
    }