Is it possible to open a Properties window?

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

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:

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

I assume it’s the wrong command ID :thinking:

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

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.

2 Likes

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

I guess it also answers this question I asked a while ago :slight_smile:

You’re welcome :slight_smile:
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 :+1:

1 Like

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


Also require('photoshop').core.performMenuCommand(6478); does not do anything for me :frowning:
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 :sweat_smile:


Bonus question :slight_smile:
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… :confused:
image


Is there some decent documentation on photoshop?

Try

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

It’s a toggle :wink:

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.

{
    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 :frowning:

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:

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:

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