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

eye dropper not select color with this code

Enthusiast ,
Sep 23, 2024 Sep 23, 2024

Copy link to clipboard

Copied

I have this code and I want to choose the color using the eye dropper, but it doesn't work. What's the problem?
I want to choose the color using the eye dropper when closing the dialogue



// Create the dialog
var dlg = new Window("dialog", "Select Color from Layers");
dlg.size = { width: 200, height: 100 };

// Add a button to the dialog
var selectColorButton = dlg.add("button", undefined, "Select Color");

// Define the button action
selectColorButton.onClick = function () {
// Close the dialog
dlg.close();

// Use a delay to ensure the dialog closes before opening the color picker

// Open the color picker
var pickedColor = app.showColorPicker(); // This allows the eyedropper to work

// Now you can do something with the selected color
if (pickedColor) {
// Process the selected color here
}
};

// Show the dialog
dlg.show();
TOPICS
Actions and scripting

Views

165

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
Adobe
Community Expert ,
Sep 23, 2024 Sep 23, 2024

Copy link to clipboard

Copied

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
Enthusiast ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

@Stephen Marsh 
Great but the link I found creates a Solider Color layer
But my problem here is that the eye dropper is not used through Dialog and closing it

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 Expert ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

@Mohamed Hameed 

 

Yes, it does create a solid colour - but you don't have to do all that:

 

    getColorpickerColor();

    /* https://graphicdesign.stackexchange.com/questions/125917/how-can-i-get-an-rgb-color-using-photoshops-color-picker-instead-of-systemss */
    function getColorpickerColor() {
        if (app.showColorPicker()) {
            return app.foregroundColor;
        } else {
            return false;
        }
    }

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
Enthusiast ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

LATEST

@Stephen Marsh 
I know that the code is done individually directly, but I use a dialogue that has a set of functions, and among those functions is choosing the color. However, when activating the color picker, the eyedropper tool does not work to select elements from the document, and the reason for this is most likely that the dialogue is active even after it is closed.

 

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