• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Scripting: Colour value (RGB) to clipboard?

Community Beginner ,
Jan 19, 2021 Jan 19, 2021

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!

TOPICS
Scripting

Views

255

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jan 19, 2021 Jan 19, 2021

 

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
...

Votes

Translate

Translate
Adobe
Guide ,
Jan 19, 2021 Jan 19, 2021

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();
};

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 20, 2021 Jan 20, 2021

Copy link to clipboard

Copied

LATEST

Thanks so much, @femkeblanco !

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines