Skip to main content
MidoSemsem
Inspiring
April 3, 2022
Answered

Convert photoshop action to script

  • April 3, 2022
  • 2 replies
  • 1371 views

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

This topic has been closed for replies.
Correct answer MidoSemsem

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()");

 


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.

2 replies

Stephen Marsh
Community Expert
Community Expert
April 3, 2022

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()");
MidoSemsem
Inspiring
April 3, 2022

It works.

Thank you very much

Stephen Marsh
Community Expert
Community Expert
April 3, 2022

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()");

 

Chuck Uebele
Community Expert
Community Expert
April 3, 2022

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. 

MidoSemsem
Inspiring
April 3, 2022

Thanks, I'll try.

Stephen Marsh
Community Expert
Community Expert
April 3, 2022

Are you using suspendHistory?  A single history step doesn't happen by default.