Skip to content

Instantly share code, notes, and snippets.

@GoodBoyNinja
Last active November 17, 2023 22:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoodBoyNinja/270287b25195e425ba989c23bc21c28e to your computer and use it in GitHub Desktop.
Save GoodBoyNinja/270287b25195e425ba989c23bc21c28e to your computer and use it in GitHub Desktop.
After-Effects Extendscript doesn't let you use the actual color picker ships with After-Effects. Using $.colorPicker() opens the OS color picker which sucks on windows. This method adds a temporary null to a comp, then uses the "Edit Value" command in order to launch the AE color picker. Once done, the function returns the data of the new color …
function GoodBoyNinjaColorPicker(startValue){
// find the active comp
var crntComp = app.project.activeItem;
if (!crntComp || !(crntComp instanceof CompItem)) {
alert("Please open a comp first");
return [];
}
// add a temp null;
var tempLayer = crntComp.layers.addShape();
var newColorControl = tempLayer("ADBE Effect Parade").addProperty("ADBE Color Control");
var theColorProp = newColorControl("ADBE Color Control-0001");
// set the value given by the function arguments
if (startValue && startValue.length == 3) {
theColorProp.setValue(startValue);
}
// prepare to execute
var editValueID = 2240 // or app.findMenuCommandId("Edit Value...");
theColorProp.selected = true;
app.executeCommand(editValueID);
// harvest the result
var result = theColorProp.value;
// remove the null
if (tempLayer) {
tempLayer.remove();
}
return result;
}
// launch the true color picker with a white color
alert(GoodBoyNinjaColorPicker([1,1,1]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment