• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Contributor ,
Jun 07, 2022 Jun 07, 2022

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?

TOPICS
Actions and scripting , Windows

Views

246

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jun 07, 2022 Jun 07, 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,

...

Votes

Translate

Translate
Adobe
Guide ,
Jun 07, 2022 Jun 07, 2022

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 07, 2022 Jun 07, 2022

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

2022-06-07_17-18-31.png

 

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);

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

Many thanks!!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 07, 2022 Jun 07, 2022

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 07, 2022 Jun 07, 2022

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 😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

That is gold!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 07, 2023 Apr 07, 2023

Copy link to clipboard

Copied

LATEST

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)?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines