3 Replies Latest reply on Jan 4, 2015 7:04 AM by Jeff Arola

    How to set levels values in adjustment layer via script?

    roffelcopter

      I try to make a script which generates a non destructive adjustment layer for levels which already sets values for shadow levels and highlight levels. I tried the scripting listener in order to record it. Unfortunately the scripting listener only records the creation of adjustment layers but not their settings like shadow or highlight levels.

      The first question here: Why can't the scripting listener do this?

       

      So I tried to do it on my own and came up with the following script which won't work. My second question therefore is, can you help me to make a script which achieves my goal? Thanks a lot. I use Photoshop CC 2014.

       

      var desc780 = new ActionDescriptor();
      desc780.putInteger( charIDToTypeID( "ShdL" ), 60 );
      desc780.putInteger( charIDToTypeID( "HghL" ), 190 );
      
      var list126 = new ActionList();
      list126.putObject( charIDToTypeID( "LvlA" ), desc780 );
      
      var desc779 = new ActionDescriptor();
      desc779.putList( charIDToTypeID( "Adjs" ), list126 );
      
      executeAction( charIDToTypeID( "Lvls" ), desc779, DialogModes.NO );
      
      
      
      

       

      Here is the script which has been recorded by the scripting listener. As you can see there is no setting of the adjustment layer.

      var idMk = charIDToTypeID( "Mk  " );
      var desc188 = new ActionDescriptor();
      var idnull = charIDToTypeID( "null" );
      var ref135 = new ActionReference();
      var idAdjL = charIDToTypeID( "AdjL" );
      ref135.putClass( idAdjL );
      desc188.putReference( idnull, ref135 );
      var idUsng = charIDToTypeID( "Usng" );
      var desc189 = new ActionDescriptor();
      var idType = charIDToTypeID( "Type" );
      var desc190 = new ActionDescriptor();
      var idpresetKind = stringIDToTypeID( "presetKind" );
      var idpresetKindType = stringIDToTypeID( "presetKindType" );
      var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
      desc190.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
      var idLvls = charIDToTypeID( "Lvls" );
      desc189.putObject( idType, idLvls, desc190 );
      var idAdjL = charIDToTypeID( "AdjL" );
      desc188.putObject( idUsng, idAdjL, desc189 );
      executeAction( idMk, desc188, DialogModes.NO );