isPanelVisible [CS5]

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: Tom, Kukurykus

Mike Hale

isPanelVisible [CS5]

Post by Mike Hale »

While looking for something else I noticed that CS5 has a new key in the capp descriptor named panelList. It's not as helpful as I had hoped but at least you can check to see if a panel is visible instead of toggling the panel it hope that it shows/hides.
Code: Select all/* some common panel names
Tools
Hand Options
Actions
Styles
Swatches
Histogram
Info:
Paths
Tool Presets
Color
Channels
Layers
Layer Comps
Animation
Clone Source
Adjustments
Masks
Measurement Log:
History
Navigator
Character
Paragraph
Notes
3D
Brush
Brush Presets
Mini Bridge
*/
isPanelVisible( 'Layers' );
function isPanelVisible( PnlName ){
   var ref = new ActionReference();
   ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
   var panelList = executeActionGet(ref).getList(stringIDToTypeID('panelList'));   
   var count = panelList.count;
   for(var i=0;i<count-5;i++){ //enumerate list
      var desc = panelList.getObjectValue(i);
      var pName = desc.getString(charIDToTypeID("Nm  "));
      if(pName == PnlName) return desc.getBoolean(charIDToTypeID("Vsbl"));
   }
}