Copy link to clipboard
Copied
Hello. I have a script containing a scriptlistener function. I am backtracking on this function to know what exactly it is doing. Unfortunately that is not going well. This is the function:
function makeSelectionFromRGB()
{
var idsetd = charIDToTypeID( "setd" );
var desc2237 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref970 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idfsel = charIDToTypeID( "fsel" );
ref970.putProperty( idChnl, idfsel );
desc2237.putReference( idnull, ref970 );
var idT = charIDToTypeID( "T " );
var ref971 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idRGB = charIDToTypeID( "RGB " );
ref971.putEnumerated( idChnl, idChnl, idRGB );
desc2237.putReference( idT, ref971 );
executeAction( idsetd, desc2237, DialogModes.NO );
}
What I know so far: It loads a selection from the RGB channel. Any ideas on what its doing, or how I may understand what it is doing?
Copy link to clipboard
Copied
@Azzam Masood – You have answered your own question! :]
Converting the code using the Clean SL script with charID's converted to stringID's provides a different angle to view the code:
makeSelectionFromRGB();
function makeSelectionFromRGB() {
var c2t = function (s) {
return app.charIDToTypeID(s);
};
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
var reference2 = new ActionReference();
reference.putProperty( s2t( "channel" ), s2t( "selection" ));
descriptor.putReference( c2t( "null" ), reference );
reference2.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( "RGB" ));
descriptor.putReference( s2t( "to" ), reference2 );
executeAction( s2t( "set" ), descriptor, DialogModes.NO );
}
Try this discussion:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/action-manager-scripting/m-p/11160326