main();
function main(){
if(!documents.length) return;
var colour =new SolidColor();
//do the first part of shade analysids
app.doAction('ShadeAnalysis1', 'Default Actions');
//set the colour you want to select in hex
colour.rgb.hexValue = 'ff0000';
//select the colour range , fuzziness, inverse(true/false)
selectColourRange(colour,15,false);
//do the next part of the analysis
app.doAction('ShadeAnalysis2', 'Default Actions');
//select a different colour ??
//colour.rgb.hexValue = 'ff00ff';
//select the colour range with a different fuzziness
selectColourRange(colour,20,false);
//do another section of the analysis
app.doAction('ShadeAnalysis3', 'Default Actions');
selectColourRange(colour,25,false);
//repeat the above steps as required
};
function selectColourRange(clr, fuzz, inverse) {
var desc = new ActionDescriptor();
desc.putInteger(charIDToTypeID("Fzns"), fuzz);
var mnDesc = new ActionDescriptor();
mnDesc.putDouble(charIDToTypeID("Lmnc"), clr.lab.l);
mnDesc.putDouble(charIDToTypeID("A "), clr.lab.a);
mnDesc.putDouble(charIDToTypeID("B "), clr.lab.b);
desc.putObject(charIDToTypeID("Mnm "), charIDToTypeID("LbCl"), mnDesc);
var mxDesc = new ActionDescriptor();
mxDesc.putDouble(charIDToTypeID("Lmnc"), clr.lab.l);
mxDesc.putDouble(charIDToTypeID("A "), clr.lab.a);
mxDesc.putDouble(charIDToTypeID("B "), clr.lab.b);
desc.putObject(charIDToTypeID("Mxm "), charIDToTypeID("LbCl"), mxDesc);
if (inverse) {
desc.putBoolean(charIDToTypeID("Invr"), inverse);
}
try{
executeAction( charIDToTypeID('ClrR'), desc, DialogModes.NO );
}catch(e){}
};