Uxp photoshop batchCall save preset

Hello, all …

Does anyone know of a way, using batchCall, to programmatically “save preset”?

When a Curves Adjustment layer is selected, the Properties Panel menu options include “Save Curves Preset …”. Invoking this menu item gives the user the chance to save the adjustment as a preset in a location of the user’s choosing.

I have attempted recording this using the Action Panel, and the recorded step is “Set current adjustment layer”. This recorded step does not include the “Save Preset” interaction.

When I use Alchemist to listen to events, Alchemist catches only two events:

  • “invokeCommand”: This looked promising, as the accompanying “_id” property (2583) is consistent across multiple attempts to catch the event. However, if I execute this using batchCall, Photoshop presents an alert: The command “<“unknown>” is not currently available.
  • “historyStateChanged”: executing via batchCall yields the same outcome as the above.

You can invoke the command through the method " performMenuCommand"

So as Alchemist records the step,

async function actionCommands() {
   const result = await batchPlay(
      [
         {
            _obj: "invokeCommand",
            commandID: 2583,
            kcanDispatchWhileModal: true,
            _options: {
               dialogOptions: "dontDisplay"
            }
         }
      ],
      {}
   );
}

It can execute the command

const r = await core.performMenuCommand({ commandID: 2583 });

Thank you! I was unaware of performMenuCommand()!

My understanding is that there is no guarantee that a commandID will stay the same for ever.

This is disconcerning. It seems strange that Adobe would provide an API (performMenuCommand) that cannot be relied upon to behave consistently. If Adobe were to document a set of commandIDs that could be relied upon, then this API might be of greater value.