# Is it possible to read if Layers Panel is enabled?

**URL:** <https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790>\
**Category:** UXP Plugin API\
**Tags:** uxp, javascript\
**Created:** [February 2, 2023, 11:20pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790 "2023-02-02T23:20:38Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![photonic](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/photonic/32/2513_2.png) [@photonic](https://forums.creativeclouddeveloper.com/u/photonic)\
**Post date:** [February 2, 2023, 11:20pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/1 "2023-02-02T23:20:38Z")

</div>

I use this function to hide or undhide the Layers Panel for my plugin workflow:

```auto
//If Layers Panel is hidden it shows it, and viceversa.
async function toggleLayersPanel() {
  await runCommandID(1098);
}

async function runCommandID(id) {
  await core.performMenuCommand({ 
    commandID: id, 
    kcanDispatchWhileModal: true, 
    _isCommand: false 
  });
}

```

However, for a better experience as a developer and bring a better UX to users, I would like to read if the Layers Panel is hidden or not. Is it possible?

Using F7 or the function above toggles the Layers Panel, but I would know if the user has the Layers Panel visible or not.

Thanks!

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [February 3, 2023, 6:21am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/2 "2023-02-03T06:21:01Z")

</div>

Get `panelList` from the app. Find panel by `panelId` (you’ll need to check what’s the ID you need). Panel has `visible` and `obscured` properties

```auto
bp([
    {
        "_obj": "get",
        "_target": [
            {"_property": 'panelList'},
            {"_ref": "application", "_enum": "ordinal", "_value": "targetEnum"},
        ],
        "_options": {"dialogOptions": "dontDisplay"}
    }
])[0]['panelList']?.find(p => p.ID === panelId)

```

---

<div class="post-metadata">

**Author:** ![photonic](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/photonic/32/2513_2.png) [@photonic](https://forums.creativeclouddeveloper.com/u/photonic)\
**Post date:** [February 4, 2023, 12:03am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/3 "2023-02-04T00:03:36Z")

</div>

Thanks Karmalakas, how is this supposed to work? Does the bp function returns anything? I tried to console.log() the result but it returns a pending promise.

```auto
const res = await batchPlay([
      {
        "_obj": "get",
        "_target": [
          { "_property": 'panelList' },
          { "_ref": "application", "_enum": "ordinal", "_value": "targetEnum" },
        ],
        "_options": { "dialogOptions": "dontDisplay" }
      }
    ])[0]['panelList']?.find(p => p.ID === panelId)

```

This gives me an error that ‘panelList’ is _unfedined_.

If I try to console.log() the next code:

```auto
const res = await batchPlay([
      {
        "_obj": "get",
        "_target": [
          { "_property": 'panelList' },
          { "_ref": "application", "_enum": "ordinal", "_value": "targetEnum" },
        ],
        "_options": { "dialogOptions": "dontDisplay" }
      }
    ]

```

It returns a pending promise. I’m kind of new with promises now in UXP so I don’t get it 100% how it works or how I could get the data from that batchPlay command.

Can you elaborate a little more? I would appreciate it! Seems I don’t get it right enough.

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [February 4, 2023, 6:04am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/4 "2023-02-04T06:04:49Z")

</div>

Oops… My bad  
Forgot to add BP options

```auto
        {
            synchronousExecution: true,
            modalBehavior: "execute"
        }

```

So it would be:

```auto
bp(
  [
    {
      "_obj": "get",
      "_target": [
        {"_property": 'panelList'},
        {"_ref": "application", "_enum": "ordinal", "_value": "targetEnum"},
      ],
      "_options": {"dialogOptions": "dontDisplay"}
    }
  ],
  {
    synchronousExecution: true,
    modalBehavior: "execute"
  }
)[0]['panelList']?.find(p => p.ID === panelId)

```

`synchronousExecution: true` here is the key to get result

It’s a bit strange that with `await batchPlay()` you get a promise, because `await` should give you a normal result and then you could get panel like this:

```auto
res[0]['panelList']?.find(p => p.ID === panelId)

```

---

<div class="post-metadata">

**Author:** ![photonic](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/photonic/32/2513_2.png) [@photonic](https://forums.creativeclouddeveloper.com/u/photonic)\
**Post date:** [February 4, 2023, 7:55pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/5 "2023-02-04T19:55:06Z")

</div>

This works now perfect Karmalakas, thank you very much!!

Is there a way that I can make visible or not a specifiic panel with some command like this one? Instead the one I have with the runCommandID() function ?

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [February 4, 2023, 8:09pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/6 "2023-02-04T20:09:26Z")

</div>

I don’t know of any. I also use command ID, which IMO must be solved by Adobe. This makes no sense to me

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [February 5, 2023, 2:25pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/7 "2023-02-05T14:25:04Z")

</div>

There have been some but those are no longer available for 3rd parties. I am not a fan of these restrictions.

You could try this one: [https://developer.adobe.com/photoshop/uxp/2022/uxp/reference-js/Modules/uxp/Plugin%20Manager/Plugin/#showpanelpanelid](https://developer.adobe.com/photoshop/uxp/2022/uxp/reference-js/Modules/uxp/Plugin%20Manager/Plugin/#showpanelpanelid) But I don’t know if that support panels that you don’t own.

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [February 5, 2023, 8:11pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/8 "2023-02-05T20:11:58Z")

</div>

From the description I understand this might actually work if you have in manifest v5 this:

```auto
"permissions": {        
    "ipc": {
        "enablePluginCommunication": true   
    }
}

```

Just not clear if this `showPanel()` is only for plugins panels or for all 🤔

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [March 12, 2023, 4:26pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/9 "2023-03-12T16:26:43Z")

</div>

I tested and can confirm that `pluginManager` is available only with permission.

---

<div class="post-metadata">

**Author:** ![Pmaxa](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pmaxa/32/2415_2.png) [@Pmaxa](https://forums.creativeclouddeveloper.com/u/Pmaxa)\
**Post date:** [February 6, 2024, 1:16pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/10 "2024-02-06T13:16:56Z")

</div>

@photonic Where did you find correct number for runCommandID?

I would like to hide some other panels

---

<div class="post-metadata">

**Author:** ![photonic](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/photonic/32/2513_2.png) [@photonic](https://forums.creativeclouddeveloper.com/u/photonic)\
**Post date:** [November 21, 2024, 6:38pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/11 "2024-11-21T18:38:26Z")

</div>

With this function you can get the list of all the panels and see their ID:

```auto
async function getPanelsList() {
    return await batchPlay([
        {
            "_obj": "get",
            "_target": [
                { "_property": 'panelList' },
                { "_ref": "application", 
                  "_enum": "ordinal", 
                  "_value": "targetEnum" },
            ],
            "_options": { "dialogOptions": "dontDisplay" }
        }
    ], {
        synchronousExecution: true,
        modalBehavior: "execute"
    })[0].panelList;
}

const panelsList = await getPanelsList();
  
console.log(panelsList);

```

And with this other function you can check if a panel is visible using its ID:

```auto
async function isPanelVisible(panelID) {
    const res = await batchPlay([
        {
            "_obj": "get",
            "_target": [
                { "_property": 'panelList' },
                { "_ref": "application",
                  "_enum": "ordinal", 
                  "_value": "targetEnum" },
            ],
            "_options": { "dialogOptions": "dontDisplay" }
        }
    ], {
        synchronousExecution: true,
        modalBehavior: "execute"
    })[0].panelList?.find(p => p.ID === panelID).visible;
    return res;
}

```

Then what you can do is use the Alchemist to listen when you hide or show the panel from the Window menu and it will log something like this, you should get the ID which will toggle the panel:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/2/26e067b8d0663e7c16e4fb194b6c8013423fc5f8.png)

Then, use the ID with this function to toggle the panel, by toggle means that if it is open the function will close it, if it is closed the function will open it:

```auto
async function runCommandID(id) {
  await core.performMenuCommand({ commandID: id, 
  kcanDispatchWhileModal: true, _isCommand: false });
}

// This toggles the Layers panel
await runCommandID(1098);

```

So use the ` isPanelVisible("panelid.static.layers")` function to see if the panel is visible and toggle it or viceversa, depends on what you want to show or hide, the `runCommandID()` remember it “toggles” the panel, not opens it estrictly, it opens if it i s closed or closes if it is opened.

Hope this is helpful!

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [November 22, 2024, 11:49am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/12 "2024-11-22T11:49:18Z")

</div>

The problem with publishing this is that Adobe might want to make this feature 1st party only in the next PS release. Same as UXP 3rd party can’t quit PS or toggle all panels even if ExtendScript DOM had API for that.

But I don’t understand how they decide what should be a first party or third party and what category this falls into.

---

<div class="post-metadata">

**Author:** ![photonic](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/photonic/32/2513_2.png) [@photonic](https://forums.creativeclouddeveloper.com/u/photonic)\
**Post date:** [November 22, 2024, 4:40pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/13 "2024-11-22T16:40:05Z")

</div>

If they do that they would be cutting our creative freedom. Hiding panels like layers, histogram, history, etc and so others ( which show pixel update data) can improve drastically UXP execution, so why doing it if the goal is going forward with better performance?? Shoud I delete the comment then?

---

<div class="post-metadata">

**Author:** ![Pmaxa](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pmaxa/32/2415_2.png) [@Pmaxa](https://forums.creativeclouddeveloper.com/u/Pmaxa)\
**Post date:** [February 20, 2025, 1:37pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-read-if-layers-panel-is-enabled/5790/14 "2025-02-20T13:37:37Z")

</div>

Hiding Photoshop UI element gave us perfomance improvement around 20-30%.  
When we are processing thousands files on server which can take hours, it’s really benefitial.
