I thought that it might be nice if it started with the color you were using at the time the script runs. That way if you are doing shading, to would already be at the current color. So here is a cleaned up commented version that does that. colorPicker(); ///////////////////////////////////////////////////////////////// // Function: colorPicker // Description: Creates a temp solidcolor adjustment layer to // let the user set the forground color then // removes the temp layer. // Usage: colorpicker() // Input: None // Return: None // Dependencies: None // Notes: ////////////////////////////////////////////////////////////////// function colorPicker(){ // create colour layer CreateSolidLayer(); // set starting color var startColor = app.foregroundColor; // call the color picker var desc = new ActionDescriptor(); var ref = new ActionReference(); ref.putEnumerated( stringIDToTypeID( "contentLayer" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) ); desc.putReference( charIDToTypeID( "null" ), ref ); var modeDesc = new ActionDescriptor(); var colorDesc = new ActionDescriptor(); colorDesc.putDouble( charIDToTypeID( "Rd " ), startColor.rgb.red ); colorDesc.putDouble( charIDToTypeID( "Grn " ), startColor.rgb.green ); colorDesc.putDouble( charIDToTypeID( "Bl " ), startColor.rgb.blue ); modeDesc.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "RGBC" ), colorDesc ); desc.putObject( charIDToTypeID( "T " ), stringIDToTypeID( "solidColorLayer" ), modeDesc ); executeAction( charIDToTypeID( "setd" ), desc, DialogModes.ALL ) // get user's color and set to forground color var ref = new ActionReference(); ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); var desc = executeActionGet(ref) var adjList = desc.getList(stringIDToTypeID('adjustment')); var adjDesc = adjList.getObjectValue(0); var colorDesc = adjDesc.getObjectValue(stringIDToTypeID('color')); var Colour = new SolidColor(); Colour.rgb.red = colorDesc.getDouble(charIDToTypeID('Rd ')); Colour.rgb.green = colorDesc.getDouble(charIDToTypeID('Grn ')); Colour.rgb.blue = colorDesc.getDouble(charIDToTypeID('Bl ')); // restore activeDocument.activeLayer.remove(); app.foregroundColor = Colour; } function CreateSolidLayer() { var desc = new ActionDescriptor(); var ref = new ActionReference(); ref.putClass( stringIDToTypeID('contentLayer') ); desc.putReference( charIDToTypeID('null'), ref ); var desc1 = new ActionDescriptor(); var desc2 = new ActionDescriptor(); var desc3 = new ActionDescriptor(); desc3.putDouble( charIDToTypeID('Rd '), 0.000000 ); desc3.putDouble( charIDToTypeID('Grn '), 0.000000 ); desc3.putDouble( charIDToTypeID('Bl '), 0.000000 ); desc2.putObject( charIDToTypeID('Clr '), charIDToTypeID('RGBC'), desc3 ); desc1.putObject( charIDToTypeID('Type'), stringIDToTypeID('solidColorLayer'), desc2 ); desc.putObject( charIDToTypeID('Usng'), stringIDToTypeID('contentLayer'), desc1 ); executeAction( charIDToTypeID('Mk '), desc, DialogModes.NO ); };
... View more