Skip to main content
jonathankemp
Inspiring
June 24, 2020
Answered

Scripting : Open specific dialogs (layer styles, color picker, etc.)

  • June 24, 2020
  • 2 replies
  • 842 views

Hey there,

 

Is there a good and safe way to open photoshop dialogs within a script ? For instance, I'd like to be able to open the "Layer Style" dialog... the one you get when you double-click a layer, or right-click and choose "Blending Options"

 I know there's a way, using the photoshop's menus with IDs and such, but I hate this solution, since the menu order could change from a PS version to another...

 

I'd rather find some better way.

 

Anyone ?

 

Thanks !

This topic has been closed for replies.
Correct answer Geppetto Luis

This is what you are looking for

 

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putProperty(cTID('Prpr'), sTID("blendOptions"));
    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
    desc1.putReference(cTID('null'), ref1);
    var desc2 = new ActionDescriptor();
    desc2.putClass(sTID("blendOptions"), sTID("blendOptions"));
    desc1.putObject(cTID('T   '), sTID("blendOptions"), desc2);
    executeAction(sTID('set'), desc1, DialogModes.ALL);

2 replies

jonathankemp
Inspiring
June 26, 2020

Thanks mate.  Works like a charm.

 

Geppetto Luis
Geppetto LuisCorrect answer
Legend
June 24, 2020

This is what you are looking for

 

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putProperty(cTID('Prpr'), sTID("blendOptions"));
    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
    desc1.putReference(cTID('null'), ref1);
    var desc2 = new ActionDescriptor();
    desc2.putClass(sTID("blendOptions"), sTID("blendOptions"));
    desc1.putObject(cTID('T   '), sTID("blendOptions"), desc2);
    executeAction(sTID('set'), desc1, DialogModes.ALL);
jonathankemp
Inspiring
July 3, 2020

Now I'm wondering about some other dialogs... like the "Mask Options" and the "Select and mask" ...

 

You've got any idea ?

Geppetto Luis
Legend
July 4, 2020

"Mask Options"

// OPTION MASK
var desc14 = new ActionDescriptor();
var ref3 = new ActionReference();
ref3.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ));
desc14.putReference( charIDToTypeID( "null" ), ref3 );
var desc15 = new ActionDescriptor();
var desc16 = new ActionDescriptor();
desc16.putUnitDouble( charIDToTypeID( "H   " ), charIDToTypeID( "#Ang" ), 183.526611 );
desc16.putDouble( charIDToTypeID( "Strt" ), 100.000000 );
desc16.putDouble( charIDToTypeID( "Brgh" ), 100.000000 );
desc15.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "HSBC" ), desc16 );
desc15.putUnitDouble( charIDToTypeID( "Opct" ), charIDToTypeID( "#Prc" ), 50.000000 );
desc14.putObject( charIDToTypeID( "T   " ), charIDToTypeID( "Chnl" ), desc15 );
executeAction( charIDToTypeID( "setd" ), desc14, DialogModes.ALL );

 

"Select and mask"

 

//Select and mask
sTID = function(s) { return app.stringIDToTypeID(s); };
executeAction(sTID('refineSelectionEdge'), undefined, DialogModes.ALL);