Skip to main content
Inspiring
June 7, 2022
Answered

Possible to record action adding new layer (e.g. B&W) using "auto" settings?

  • June 7, 2022
  • 2 replies
  • 690 views

I am frequently recording actions, but have not (yet) learned to write scripts. Is is possible to make the adjustments to "auto" when adding e.g. a B&W layer in a recorded action?

This topic has been closed for replies.
Correct answer jazz-y

 

s2t = stringIDToTypeID;

(r = new ActionReference()).putEnumerated(s2t("adjustmentLayer"), s2t("ordinal"), s2t("targetEnum"));
(d = new ActionDescriptor()).putReference(s2t("target"), r);
(d1 = new ActionDescriptor()).putEnumerated(s2t("presetKind"), s2t("presetKindType"), s2t("presetKindCustom"));
d1.putBoolean(s2t("auto"), true);
d.putObject(s2t("to"), s2t("blackAndWhite"), d1);
executeAction(s2t("set"), d, DialogModes.NO);

 

Save this code to a text file, change the file extension to .jsx, place the file in the Photoshop presets directory (Adobe Photoshop 2022\Presets\Scripts). After restarting Photoshop you will see this script in File->Scripts menu

 

Select the Black&White adjustment layer and then run the script. It will apply auto-values. If necessary, the script call can be written into an action.

2 replies

Inspiring
April 7, 2023

I have used jazz-y's solution so much this past year and am so grateful. However, for some reason it no longer works. It is installed in my Photoshop 2023, I can open and run the script, but nothing happens. Does anyone know if I need to adjust the scrip in some way (because of Photoshop updates)?

jazz-yCorrect answer
Legend
June 7, 2022

 

s2t = stringIDToTypeID;

(r = new ActionReference()).putEnumerated(s2t("adjustmentLayer"), s2t("ordinal"), s2t("targetEnum"));
(d = new ActionDescriptor()).putReference(s2t("target"), r);
(d1 = new ActionDescriptor()).putEnumerated(s2t("presetKind"), s2t("presetKindType"), s2t("presetKindCustom"));
d1.putBoolean(s2t("auto"), true);
d.putObject(s2t("to"), s2t("blackAndWhite"), d1);
executeAction(s2t("set"), d, DialogModes.NO);

 

Save this code to a text file, change the file extension to .jsx, place the file in the Photoshop presets directory (Adobe Photoshop 2022\Presets\Scripts). After restarting Photoshop you will see this script in File->Scripts menu

 

Select the Black&White adjustment layer and then run the script. It will apply auto-values. If necessary, the script call can be written into an action.

Inspiring
June 7, 2022

Fantastic! Many thanks, this has solved a task which has slowed me down for a long time.
Is there a similar smooth way of doin the same but for a "levels" layer?

Legend
June 7, 2022

 

s2t = stringIDToTypeID;
(r = new ActionReference()).putEnumerated(s2t("adjustmentLayer"), s2t("ordinal"), s2t("targetEnum"));
(d = new ActionDescriptor()).putReference(s2t("target"), r);
(r1 = new ActionReference()).putEnumerated(s2t("channel"), s2t("channel"), s2t("composite"));
(d1 = new ActionDescriptor()).putReference(s2t("channel"), r1);

//enhance monochromatic conrast
//d1.putBoolean( s2t( "autoContrast" ), true );

//enhance per channel contrast
//d1.putBoolean( s2t( "auto" ), true );

//find dark and light colors
// d1.putBoolean( s2t( "autoBlackWhite" ), true );

//default: enhance brightness and contrast
d1.putBoolean(s2t("autoMachineLearning"), true);
d1.putBoolean(s2t("autoFaces"), true);
//

(l = new ActionList()).putObject(s2t("levelsAdjustment"), d1);
(d2 = new ActionDescriptor()).putList(s2t("adjustment"), l);
d.putObject(s2t("to"), s2t("levels"), d2);
executeAction(s2t("set"), d, DialogModes.NO);