Copy link to clipboard
Copied
Hi,
I'm using Photoshop 2022 on Windows. I'm trying to convert an Action to Script.
The problem is that the action has many steps and I want to undo the action entirely in one step.
I've converted the action into a script by Xtools, but it works exactly as an action.
Please help
Copy link to clipboard
Copied
Is this an action that you created? Frankly, I would use scriptListener and redo the steps if the action to generate the javascript code from scriptListener.
Copy link to clipboard
Copied
Thanks, I'll try.
Copy link to clipboard
Copied
Are you using suspendHistory? A single history step doesn't happen by default.
Copy link to clipboard
Copied
I think that it can be done otherwise, however, I have only had success wrapping the script into a function and then using suspend history by calling the function.
function main () {
//your code here
}
activeDocument.suspendHistory("Run script", "main()");
Copy link to clipboard
Copied
It works.
Thank you very much
Copy link to clipboard
Copied
I believe that you can also just call the action directly:
function main () {
app.doAction("Molten Lead","Default Actions");
}
activeDocument.suspendHistory("Undo Molten Lead action", "main()");
Copy link to clipboard
Copied
I did it this way and it worked.
I also replaced
app.doAction("Molten Lead","Default Actions");
with the script generated by Xtool and it worked. I can now save it as a complete separate script without the need for an existing action.