Copy link to clipboard
Copied
Hey guys,
Some time ago, I had a question about using javascript to perform a select color range. It works, but it uses whatever sample options were set before running the script. It would be nice if I were able to set the Sample option to "Current Layer" via script.
Is there a way to do that?
CC2018
...// remember old tool
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("tool"));
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var curr_tool = executeActionGet(r).getEnumerationType(stringIDToTypeID("tool"));
// select eyedropper tool
var r = new ActionReference();
r.putClass(stringIDToTypeID("eyedropperTool"));
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
execut
Copy link to clipboard
Copied
CC2018
// remember old tool
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("tool"));
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var curr_tool = executeActionGet(r).getEnumerationType(stringIDToTypeID("tool"));
// select eyedropper tool
var r = new ActionReference();
r.putClass(stringIDToTypeID("eyedropperTool"));
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
// get and set eyedropper tool options
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("tool"));
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var op = executeActionGet(r).getObjectValue(stringIDToTypeID("currentToolOptions"));
op.putInteger(stringIDToTypeID("eyeDropperSample"), 0); // point sample
op.putInteger(stringIDToTypeID("eyeDropperSampleSheet"), 1); // current layer
var r = new ActionReference();
r.putClass(stringIDToTypeID("eyedropperTool"));
var d = new ActionDescriptor();
d.putReference( stringIDToTypeID( "null" ), r );
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("null"), op);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
// select old tool
var r = new ActionReference();
r.putClass(curr_tool);
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
Copy link to clipboard
Copied
awesome. thanks!