Convert photoshop action to script

Community Beginner ,
Apr 03, 2022 Apr 03, 2022

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

TOPICS
Actions and scripting

Views

128

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Apr 03, 2022 Apr 03, 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()");

Likes

Translate

Translate
Adobe Community Professional ,
Apr 03, 2022 Apr 03, 2022

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. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 03, 2022 Apr 03, 2022

Copy link to clipboard

Copied

Thanks, I'll try.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 03, 2022 Apr 03, 2022

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 03, 2022 Apr 03, 2022

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 03, 2022 Apr 03, 2022

Copy link to clipboard

Copied

It works.

Thank you very much

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 03, 2022 Apr 03, 2022

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

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 03, 2022 Apr 03, 2022

Copy link to clipboard

Copied

LATEST

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines