Within an Action I have the user make a selection using the color range tool for example. Following the selection I'd like the Action to generate a new Channel (not Layer) with the new foreground color chosen by the user.
So far, this seems impossible to do without including stops to click the Color Chip in the New Channel box, followed by clicking the Foreground Color to change it and so on.
Anyhow, is it possible to write some type of script that uses the "current foreground color" to generate a new Channel?
As you can see by the attached graphic, when the New Channel dialog box appears, it never indicates the current foreground color and a few manual steps are always needed to be implemented which I'd like to avoid by the use of a script if possible.
Is This Possible To Do?
Is This Possible To Do?
Try this:
Code: Select allfunction newChannel() {
function cTID(s) { return app.charIDToTypeID(s); };
var fg = app.foregroundColor;
var desc20 = new ActionDescriptor();
var desc21 = new ActionDescriptor();
desc21.putEnumerated( cTID('ClrI'), cTID('MskI'), cTID('SlcA') );
var desc22 = new ActionDescriptor();
desc22.putDouble( cTID('Rd '), fg.rgb.red );
desc22.putDouble( cTID('Grn '), fg.rgb.green );
desc22.putDouble( cTID('Bl '), fg.rgb.blue );
desc21.putObject( cTID('Clr '), cTID('RGBC'), desc22 );
desc21.putInteger( cTID('Opct'), 100 );
desc20.putObject( cTID('Nw '), cTID('Chnl'), desc21 );
executeAction( cTID('Mk '), desc20, DialogModes.NO );
};
newChannel();
Code: Select allfunction newChannel() {
function cTID(s) { return app.charIDToTypeID(s); };
var fg = app.foregroundColor;
var desc20 = new ActionDescriptor();
var desc21 = new ActionDescriptor();
desc21.putEnumerated( cTID('ClrI'), cTID('MskI'), cTID('SlcA') );
var desc22 = new ActionDescriptor();
desc22.putDouble( cTID('Rd '), fg.rgb.red );
desc22.putDouble( cTID('Grn '), fg.rgb.green );
desc22.putDouble( cTID('Bl '), fg.rgb.blue );
desc21.putObject( cTID('Clr '), cTID('RGBC'), desc22 );
desc21.putInteger( cTID('Opct'), 100 );
desc20.putObject( cTID('Nw '), cTID('Chnl'), desc21 );
executeAction( cTID('Mk '), desc20, DialogModes.NO );
};
newChannel();
Is This Possible To Do?
Thanks Xbytor....I'll give this a try tomorrow when I get to work. Much appreciated.
Is This Possible To Do?
Decided to try it out now. It works! Must have played around with that on and off for weeks. I can't thank you enough. You are a scripts wizard my friend. Making a donation to the site now. $20 but maybe you guys can have a few beers on me. Thanks again!