The code I figured out works fine for simple actions.
However, if an an action contains dialogs, it becomes unusable.
For example, if the action contains a Gaussian blur (with dialog),
the UXP progress bar appears and the Gaussian blur dialog freezes -
it is almost impossible to move the slider and also the preview does not
work correctly.
The situation becomes even worse if the action contains further dialogs.
Here is my code:
const app = require('photoshop').app;
const executeAsModal = require('photoshop').core.executeAsModal;
async function playAction(aName,aSetName){
const actionSet=app.actionTree.find(as=>as.name===aSetName);
const action=actionSet?actionSet.actions.find(a=>a.name===aName):null;
if( action==null ){
throw `Action not found:${aName} / ${aSetName}`;
}
await executeAsModal( async()=>{
action.play();
},{'commandName':'Play action bla bla...'});
}
Is there a way to solve this problem? Or am I missing an important step?
Thanks.
P.S. I also used Alchemist to figure out the batch play code needed to play an action, but the
same problem ocurs.
I just realized that the same problem arises if a filter is executed via batch play like this:
await executeAsModal(async()=>{
const result = await batchPlay(
[
{
_obj: "gaussianBlur",
radius: {
_unit: "pixelsUnit",
_value: 3
},
_options: {
dialogOptions: "display"
}
}
],{
synchronousExecution: false,
modalBehavior: "wait"
});
},{'commandName':'Blur it!'});
}
Same behavior: The dialog of the Gaussian blur filter is shown, but as soon
as the slider is moved, the progress bar appears and the dialog becomes unusable.
Yet another remark: This seems to be a new “feature” in PS 23.1.
When I roll back to PS 23.0.2 everything works fine.