Copy link to clipboard
Copied
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?
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,
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
Many thanks!!!!
Copy link to clipboard
Copied
@jazz-y excellent work, when it wasn't recorded in an action or script listener log my only hope was for someone with advanced AM code knowledge to step up!
Copy link to clipboard
Copied
Actually the scriptListener shows it. Not for an adjustment layer, but for a regular tool window. I just took the settings from there and copied them to an adjustment layer 😉
Copy link to clipboard
Copied
That is gold!
Copy link to clipboard
Copied
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)?