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

Close the Histogram Palette only if it's open

Community Beginner ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

Hello,

is there a way to know if the Histogram Palette is already open and if it is as such close it? 

I know this:

app.runMenuItem (app.stringIDToTypeID ("toggleHistogramPalette"));

but how to know if the Palette is opened or closed? If I run the above line of code the Palette will be opening and I want to close it only if it is opened.

Obviously I'll reopen it at the end of my script as per the User Preference

An alternative could be to alt the refresh of it during the run of the script.

Thank you in advance,

BR

TOPICS
Actions and scripting

Views

661

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 Beginner ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

I found how to know if it is opened or not, maybe would be more elegant to halt its refreshing instead of closing. Can it be done?

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 ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

What I do to speed up scripts it to simply toggle all Photoshop's palettes before a heavy processing loop and toggle them again when the loop finishes it job.  app.togglePalettes();  I believe only  the Photoshop palettes that are open to begin with toggle.

JJMack

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 ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

Thank for your reply JJMack.

I know about the togglePalettes(), I was trying to be less intrusive as possible in the User Experience.

However togglePalettes() or runMenuItem(...(toggleSomething)) don't check if whatever you're trying to toggle is already open: if it's closed it will open it, if open it will close it.

The best thing possible would be to be able to disable screen updating while running a script.

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 ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

There is also a difference between Toggle and Close.  If a user has the histogram panel open why would you close it on them.  That seem more intrusive then toggling it twice they will still have their Photoshop UI in the state they were using.   If you close  it on them IMO you should open it back up for them

JJMack

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 ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

You're correct, as I stated before "obviously I'll reopen it at the end of my script as per the User Preference".

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
Guide ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

This will close the Histogram palette only if it is open.

#target photoshop;

var panelList = listPanels();

for(var a in panelList){

    if(panelList[0].toString().match(/Histogram/) && panelList[1]){

        app.runMenuItem (stringIDToTypeID ("closeHistogramPanel"));

        break;

        }

    }

function listPanels(){

var ref = new ActionReference();

Info = new Array();

ref.putProperty( charIDToTypeID("Prpr"), stringIDToTypeID("panelList") );

ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var desc = executeActionGet(ref).getList (stringIDToTypeID("panelList"));

for(var a = 0;a<desc.count;a++){

var Name = desc.getObjectValue(a).getString (stringIDToTypeID("name"));

var Vis = desc.getObjectValue(a).getBoolean(stringIDToTypeID("visible"));

var Ob = desc.getObjectValue(a).getBoolean(stringIDToTypeID("obscured"));

var ID = desc.getObjectValue(a).getString(stringIDToTypeID("ID"));

Info.push([[Name],[Vis],[Ob],[ID]]);

    }

return Info;

};

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 ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

Thank you, I used something similar.

Do you happen to know if it is possible to disable Screen Updating using the Action Descriptor?

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
Guide ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

Not that I know of.

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 ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

Not that I know of that is why I toggle palette off.   Updating Photoshops UI slow down script execution. The UI is also not completely updated for each step you would need to add a refresh for that after each thing the script does which would make the script creep.   I toggle Palettes of and use refresh when I want the give the user interactive control so they will see the document current state. I do not care if the image rendering lags behind the scripts execution that does not slow the scripts execution that much and there is no way that in know of that a script can minimize  Photoshop window or image window so the script will execute faster.

JJMack

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 ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

Hi @SuperMerlin,

good stuff

And with a small change in your code in lines #05 and #06 will toggle the histogram palette (only if the palette is open)

#target photoshop

var panelList = listPanels();

for( var a in panelList ){

    //if( panelList[0].toString().match(/Histogram/) && panelList[1] ){

        //app.runMenuItem ( stringIDToTypeID ("closeHistogramPanel") );

    if( panelList[0].toString().match(/Histogram/) && panelList[1] == "true" ){

        app.runMenuItem ( stringIDToTypeID ("toggleHistogramPalette") );

        break;

        }

    }

function listPanels(){

var ref = new ActionReference();

Info = new Array();

//ref.putProperty( charIDToTypeID('Prpr'), stringIDToTypeID("panelList") );

//ref.putEnumerated( charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

ref.putProperty( stringIDToTypeID("property"), stringIDToTypeID("panelList") );

ref.putEnumerated( stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum") );

var desc = executeActionGet(ref).getList( stringIDToTypeID("panelList") );

for( var a = 0; a<desc.count; a++ ){

    var Name = desc.getObjectValue(a).getString( stringIDToTypeID("name") );

    var Vis = desc.getObjectValue(a).getBoolean( stringIDToTypeID("visible") );

    var Ob = desc.getObjectValue(a).getBoolean( stringIDToTypeID("obscured") );

    var ID = desc.getObjectValue(a).getString( stringIDToTypeID("ID") );

    Info.push( [[Name], [Vis], [Ob], [ID]] );

    }

return Info;

};

And thx for sharing

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 ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

LATEST

Hmmh?

What's the matter with jive???

helpful doesn't works

mention doesn't works

edit doesn't works

Two weeks later:

helpful doesn't works

edit doesn't works

mention still doesn't works

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