11 Replies Latest reply on May 16, 2017 10:38 AM by pixxxel schubser

    Close the Histogram Palette only if it's open

    Alberto_aa

      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

        • 1. Re: Close the Histogram Palette only if it's open
          Alberto_aa Level 1

          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?

          • 2. Re: Close the Histogram Palette only if it's open
            JJMack Most Valuable Participant

            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.

            • 3. Re: Close the Histogram Palette only if it's open
              Alberto_aa Level 1

              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.

              • 4. Re: Close the Histogram Palette only if it's open
                SuperMerlin Level 5

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

                 

                #target photoshop;
                
                var panelList = listPanels();
                for(var a in panelList){
                    if(panelList[a][0].toString().match(/Histogram/) && panelList[a][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;
                };
                
                
                
                1 person found this helpful
                • 5. Re: Close the Histogram Palette only if it's open
                  Alberto_aa Level 1

                  Thank you, I used something similar.

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

                  • 7. Re: Close the Histogram Palette only if it's open
                    JJMack Most Valuable Participant

                    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

                    • 8. Re: Close the Histogram Palette only if it's open
                      JJMack Most Valuable Participant

                      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.

                      • 9. Re: Close the Histogram Palette only if it's open
                        Alberto_aa Level 1

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

                        • 10. Re: Close the Histogram Palette only if it's open
                          pixxxel schubser MVP & Adobe Community Professional

                          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[a][0].toString().match(/Histogram/) && panelList[a][1] ){
                                  //app.runMenuItem ( stringIDToTypeID ("closeHistogramPanel") );
                              if( panelList[a][0].toString().match(/Histogram/) && panelList[a][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

                           

                          1 person found this helpful
                          • 11. Re: Close the Histogram Palette only if it's open
                            pixxxel schubser MVP & Adobe Community Professional

                            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