Copy link to clipboard
Copied
Hi guys,
Is there an script option to copy a colour value of a selected object to clipboard? I have stumbled upon some script snippets all accross the Interweb; however, I wasn't able to find a full, working .jsx file to use as script. The best I have found was an option of exporting the swatches' values to a txt file, nevertheless, this didn't work for me as there were plenty of colour in the file and I'd lose track of which is which.
Simply selecting the object, running the script and ending up with three numbers in the Clipboard would be sufficient.
Thanks!
if (app.selection.length != 1 || app.selection[0].typename != "PathItem") {
alert( "Select one pathItem." );
} else if (app.selection[0].fillColor.typename != "RGBColor") {
alert( "Color is not RGB." );
} else {
var AR = app.activeDocument.artboards[0].artboardRect;
var rect1 = app.activeDocument.pathItems.rectangle(0, AR[2]-100, 100, 100);
var R = Math.round(app.selection[0].fillColor.red),
G = Math.round(app.selection[0].fillColor.green),
B = Math.round(app.sele
...
Copy link to clipboard
Copied
if (app.selection.length != 1 || app.selection[0].typename != "PathItem") {
alert( "Select one pathItem." );
} else if (app.selection[0].fillColor.typename != "RGBColor") {
alert( "Color is not RGB." );
} else {
var AR = app.activeDocument.artboards[0].artboardRect;
var rect1 = app.activeDocument.pathItems.rectangle(0, AR[2]-100, 100, 100);
var R = Math.round(app.selection[0].fillColor.red),
G = Math.round(app.selection[0].fillColor.green),
B = Math.round(app.selection[0].fillColor.blue);
var text0 = app.activeDocument.textFrames.areaText(rect1);
text0.contents = R + ", " + G + ", " + B;
app.selection = null;
app.activeDocument.pageItems[0].selected = true;
app.cut();
};
Copy link to clipboard
Copied
Thanks so much, @femkeblanco !