Edited at

Photoshopのオーバーレイマスクカラーを3種トグルするJavaScript

More than 1 year has passed since last update.



#target photoshop

var myRegKey ="myMaskColor";
var myDefHSBS = 80; //彩度
var myDefHSBB = 80; //輝度

try{ //キーが無い初回起動時作成
var customActionDescriptor = app.getCustomOptions(myRegKey);
var myColor = customActionDescriptor.getString(1001);
}catch(e){
var myColor = myPutString (0)
}

var myColor=Number(myColor)+120; //120度プラスで、赤・緑・青をトグル
if(myColor>=360){myColor=0};
myPutString (myColor);

try{
executeChangeColor(myColor);
}catch(e){}

function myPutString(myH){
var desc = new ActionDescriptor();
desc.putString(1001,myH);
app.putCustomOptions(myRegKey, desc, true);
return myH;
}

function executeChangeColor(myHSBsH){
var idsetd = charIDToTypeID( 'setd' );
var desc12 = new ActionDescriptor();
var idnull = charIDToTypeID( 'null' );
var ref3 = new ActionReference();
var idChnl = charIDToTypeID( 'Chnl' );
var idOrdn = charIDToTypeID( 'Ordn' );
var idTrgt = charIDToTypeID( 'Trgt' );
ref3.putEnumerated( idChnl, idOrdn, idTrgt );
desc12.putReference( idnull, ref3 );
var idT = charIDToTypeID( 'T ' );
var desc13 = new ActionDescriptor();
var idClr = charIDToTypeID( 'Clr ' );
var desc14 = new ActionDescriptor();
var idH = charIDToTypeID( 'H ' );
var idAng = charIDToTypeID( '#Ang' );
desc14.putUnitDouble( idH, idAng, myHSBsH );
var idStrt = charIDToTypeID( 'Strt' );
desc14.putDouble( idStrt, myDefHSBS );
var idBrgh = charIDToTypeID( 'Brgh' );
desc14.putDouble( idBrgh, myDefHSBB );
var idHSBC = charIDToTypeID( 'HSBC' );
desc13.putObject( idClr, idHSBC, desc14 );
var idChnl = charIDToTypeID( 'Chnl' );
desc12.putObject( idT, idChnl, desc13 );
executeAction( idsetd, desc12, DialogModes.NO );
}