# Is it possible to open a Properties window?

**URL:** <https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074>\
**Category:** UXP Plugin API\
**Created:** [June 9, 2021, 9:57pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074 "2021-06-09T21:57:56Z")\
**Posts on this page:** 19\
**Page:** 1

<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:** [June 9, 2021, 9:57pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/1 "2021-06-09T21:57:56Z")

</div>

I want to open Properties window (if not open) from a plugin. Alchemist gives me this:

```auto
const batchPlay = require("photoshop").action.batchPlay;

const result = await batchPlay(
[
   {
      "_obj": "invokeCommand",
      "commandID": 6478,
      "kcanDispatchWhileModal": true,
      "_isCommand": false,
      "_options": {
         "dialogOptions": "dontDisplay"
      }
   }
],{
   "synchronousExecution": false,
   "modalBehavior": "fail"
});

```

But getting error:

```nohighlight
The command “<unknown>” is not currently available.

```

I assume it’s the wrong command ID 🤔

Also tried `"kcanDispatchWhileModal": false`, but no luck 🙁  
Any advice? Or is this not possible at all?

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 9, 2021, 10:41pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/2 "2021-06-09T22:41:47Z")

</div>

The command ID is correct, you can execute menu items via  
`photoshop.core.performMenuCommand({ commandID });`

You can read out the `visible` and `obscured` state from the app property `panelList`.

Btw, if you need to find the command ID for a dynamically added menu item (like a plugin), you can access it via the app property `menuBarInfo`, by traversing the submenus and matching by the panel titel.

---

<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:** [June 10, 2021, 6:25am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/3 "2021-06-10T06:25:10Z")

</div>

Awesome. Thank you so much. That’s much more info than I asked, but was wondering about the other day 🙂 Will try to implement after work.

I guess it also answers [this question](http://forums.creativeclouddeveloper.com/t/how-to-call-command-of-another-plugin/3043) I asked a while ago 🙂

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 10, 2021, 9:15am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/4 "2021-06-10T09:15:08Z")

</div>

You’re welcome 🙂  
Ah, indeed! When I read the other post the first time I thought you were trying to click a button or run a function of another panel, which is not possible. But calling a menu command should work fine the way I’ve described above 👍

---

<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:** [June 10, 2021, 4:47pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/5 "2021-06-10T16:47:05Z")

</div>

> [@simonhenke](#):
>
> You can read out the `visible` and `obscured` state from the app property `panelList`

Where exactly is this `panelList`? `require('photoshop').app` doesn’t have such property 🤔 Same question for `menuBarInfo`

* * *

Also `require('photoshop').core.performMenuCommand(6478);` does not do anything for me ☹  
I’m getting:

> Error: Argument 1 has an invalid type. Expected type: object actual type: number

~~What kind of object should I pass?~~  
Nevermind, figured the `{}` in your example was what I needed and not just a template-like syntax 😅

* * *

Bonus question 🙂  
Is there a way to hide/close Properties window? Alchemist gives the exact same code snippet I posted initially, and in console it seems I can’t make it work at all… 😕  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/5/597d9fd4ea482fb7ddafe7632dcd32a4522bdca0.png)

* * *

Is there some decent documentation on `photoshop`?

---

<div class="post-metadata">

**Author:** ![Pierre\_G](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pierre_g/32/971_2.png) [@Pierre\_G](https://forums.creativeclouddeveloper.com/u/Pierre_G)\
**Post date:** [June 10, 2021, 5:23pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/6 "2021-06-10T17:23:40Z")

</div>

Try

```auto
const psCore = require('photoshop').core;
psCore.performMenuCommand({ "commandID": 6478 });

```

It’s a toggle 😉

---

<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:** [June 10, 2021, 5:36pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/7 "2021-06-10T17:36:03Z")

</div>

Aha, that works now in console and it toggles, but I can’t make it work in Ps via a menu plugin command. The Properties window opens the first time, but then it won’t close, but always keeps opening. I guess it’s because it’s not in focus when I click the menu.

Also I figured how to get `panelList` with Alchemist inspector, but for Properties I always get visible/obscured `false`. I guess this explains why window does not toggle, but always opens.

```auto
{
    ID: "panelid.static.smartbrush"
    name: "Properties"
    obscured: false
    visible: false
    _obj: "panelList"
}

```

Any suggested workaround?

* * *

Here’s the action. No matter if “Properties” window is closed or open, the result is always the same ☹

```auto
require('photoshop').action.batchPlay([
            {
                "_obj": "get",
                "_target": [
                    {"_property": "panelList"},
                    {"_ref": "application", "_enum": "ordinal", "_value": "targetEnum"}
                ]
            }
        ], {
        synchronousExecution: true,
        modalBehavior: 'execute'
    })[0].panelList[44]

```

Not sure if index is always 44, but seems like it

* * *

Also tried to get the state directly from `core`:

```auto
core.getMenuCommandState({"commandID":menuItem.command});

```

But this always returns `[true]`

* * *

Tried to get directly from `menuBarInfo` and see if menu is checked, but the result is always:

```auto
{
    "name":"Properties",
    "visible":true,
    "enabled":true,
    "checked":false
}

```

---

<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:** [June 18, 2021, 8:14am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/8 "2021-06-18T08:14:11Z")

</div>

> [@Karmalakas](#):
>
> Also tried to get the state directly from `core` :
> 
> ```auto
> core.getMenuCommandState({"commandID":menuItem.command});
> 
> ```
> 
> But this always returns `[true]`
> 
> Tried to get directly from `menuBarInfo` and see if menu is checked, but the result is always:
> 
> ```auto
> {
> "name":"Properties",
> "visible":true,
> "enabled":true,
> "checked":false
> }
> 
> ```

Anyone any ideas on how to get the correct status of the panel/window so I could toggle only if needed? 🙄

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 18, 2021, 8:57am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/9 "2021-06-18T08:57:12Z")

</div>

Could you summarize again, which behavior you’d like to see?  
I just tested said menuCommand from

1. the console
2. inside a panel
3. a plugin menu command

and in all cases it worked fine, by showing the properties window when it’s hidden and hiding it when it is shown.

---

<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:** [June 18, 2021, 9:03am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/10 "2021-06-18T09:03:21Z")

</div>

The main question is - how do I prevent panel from hiding if it’s visible (or vice versa - prevent showing if it’s hidden). Or even bring it to front if it’s behind other panel? So basically I didn’t find a proper way to check the state, so that I could prevent a toggle if not needed

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 18, 2021, 9:52am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/11 "2021-06-18T09:52:34Z")

</div>

Hm, for my plugin this worked fine at least.

Here’s the relevant part:

```auto
 const panelState = getAppProperty('panelList').find(p => p.name === panelName)
  if (!panelState.visible || panelState.obscured) {
    performMenuCommand(panel.command)
  }

```

And when I test it with Alchemist specifically for the Properties Panel, I also seem to get the correct result:  
Not opened:

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

opened:

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

Maybe I’m not seeing the issue yet, or it’s just a problem on your side 🤔

---

<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:** [June 18, 2021, 9:55am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/12 "2021-06-18T09:55:29Z")

</div>

That’s weird 🤔 I will re-check again, but when I tried, I had:

> [@Karmalakas](#):
>
> Also I figured how to get `panelList` with Alchemist inspector, but for Properties I always get visible/obscured `false` . I guess this explains why window does not toggle, but always opens.
> 
> ```auto
> {
> ID: "panelid.static.smartbrush"
> name: "Properties"
> obscured: false
> visible: false
> _obj: "panelList"
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 18, 2021, 9:57am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/13 "2021-06-18T09:57:15Z")

</div>

`panelid.static.smartbrush` is not really the panel that you want, is it

---

<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:** [June 18, 2021, 10:13am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/14 "2021-06-18T10:13:49Z")

</div>

But it’s the only in list I see named “Properties” 😕

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 18, 2021, 10:23am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/15 "2021-06-18T10:23:50Z")

</div>

You can find that out easily if you hide/show the properties panel and add the Application/panelList descriptor in Alchemist each time. If you then compare both for the differences, you should see which one you toggled.

---

<div class="post-metadata">

**Author:** ![Pierre\_G](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pierre_g/32/971_2.png) [@Pierre\_G](https://forums.creativeclouddeveloper.com/u/Pierre_G)\
**Post date:** [June 18, 2021, 11:23am UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/16 "2021-06-18T11:23:40Z")

</div>

In the past i’ve used something like this:

```auto
function get_panelList() {
  return batchPlay(
    [{
      "_obj": "get",
      "_target": [{
          "_property": "panelList"
        },
        {
          "_ref": "application",
          "_enum": "ordinal",
          "_value": "targetEnum"
        }
      ]
    }], {
      "synchronousExecution": true
    })[0].panelList;
}

function showPropertiesPanel() {
  const panelStatus = get_panelList().find(panel => panel.name === "Properties")
  if (!panelStatus.visible || panelStatus.obscured) {
    require('photoshop').core.performMenuCommand({
      "commandID": 6478
    });
  }
}

```

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 18, 2021, 12:40pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/17 "2021-06-18T12:40:52Z")

</div>

That’s exactly what I’ve posted above 😃

---

<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:** [June 18, 2021, 4:04pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/18 "2021-06-18T16:04:36Z")

</div>

OK… So what’s the deal?  
If I do `const panelState = getAppProperty('panelList')` and add a breakpoint, in console I find manually the `Properties` panel and it’s:

```json
{
    ID: "panelid.static.smartbrush"
    name: "Properties"
    obscured: false
    visible: false
    _obj: "panelList"
}

```

But after `.find(panel => panel.name === "Properties")` I get:

```json
{
    ID: "panelid.static.properties"
    name: "Properties"
    obscured: false
    visible: false
    _obj: "panelList"
}

```

How come in console it’s the different panel with the same name when whole list is expanded?  
And I guess it’s better to search by ID, than by name (noticed name is different in other languages)

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 18, 2021, 7:17pm UTC](https://forums.creativeclouddeveloper.com/t/is-it-possible-to-open-a-properties-window/3074/19 "2021-06-18T19:17:10Z")

</div>

That’s weird indeed. And yes, matching by ID is always the better option. I only used it for panels of my own plugin, so matching by name works fine, too, in this case.
