How to call HDR command?

This is the code I’m listening to, but it doesn’t work.

require("photoshop").action.batchPlay([
   {
      "_obj": "AdobeScriptAutomation Scripts",
      "javaScript": {
         "_path": "C:\\Program Files\\Adobe\\Adobe Photoshop 2021\\Required\\HDRToning.jsx",
         "_kind": "local"
      },
      "javaScriptMessage": "undefined",
      "_isCommand": true,
      "_options": {
         "dialogOptions": "display"
      }
   }
],{"synchronousExecution": false,"modalBehavior": "fail"});

You have to use a token instead of path.

Hello, how to use the token

It’s finally working!

var tempFun = async function () {

    const PluginFolder = await FS.getPluginFolder();

    const theTemplate = await PluginFolder.getEntry("HDRToning.jsx");

    const Token=await FS.createSessionToken(theTemplate);

    await PS.action.batchPlay([{

        "_obj": "AdobeScriptAutomation Scripts",

        "javaScript": {

            "_path": Token,

            "_kind": "local"

        },

        "javaScriptMessage": "undefined",

        "_isCommand": true

    }], {});

}

tempFun();

Hey there – I’m glad you found a solution. Note, however, that this is not going to work long-term, as ExtendScript is not technically supported by UXP. As such, it’s likely that the mechanism you’re using here will stop working. Furthermore, it requires redistributing part of Photoshop (HDRToning.jsx) alongside your plugin, which is also not something you should do.

(In general: if you need to execute ExtendScript, the correct way to do that in UXP is to convert that ExtendScript to modern JavaScript. Adobe does not support interfacing with ExtendScript from UXP.)

I’m sure there’s a batchPlay command to do this equivalent, however, this works just as well:

const core=require("photoshop").core;
core.performMenuCommand({
    title: core.translateUIString("$$$/Menu/Adjust/HDRToning")
});

If this doesn’t fully meet your needs, please describe in more detail how you’re using the HDR Toning feature, and we can help further.

3 Likes

Thank you very much, this is exactly the code I want