Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Having troubles running an action via Python

Explorer ,
Aug 04, 2021 Aug 04, 2021

Copy link to clipboard

Copied

So I discovers this really nifty api that allows you to control photoshop with python using win32com. (More info: photoshop-scripting-python!)

 

What i want my code to do is run a diffrent action on a JPEG depending on the name of the file it's located in. That part will be relativly easy to code out. The problem i run into is whne trying to run the action via python photoshop gives me the following error "The command 'play' is not currently available"

 

By doing some googling i've found  that this error is displayed when some step in the action isn't behaving as it should. This could be due to a multitude of problems listed here: "The command “Play” is not currently available." - an action within an action.

 

Currently my code looks like this:

 

from win32com.client import Dispatch
import os

psApp = Dispatch("Photoshop.Application")
folder = 'C:\\This\\is\\the\\path\\to\\my\\folder'

for root, direc, files in os.walk(folder):
    for file in files:
        image = os.path.join(root, file)
        doc = psApp.Open(image)
        doc.Selection.Deselect()
        psApp.DoAction('Action Folder', 'Action')

 

Thus far I have tried deleting steps from my action inoreder to determain which step is giveing me the error. Up until the point where all i'm doing is changeing the image size nad it still doesn't work.

 

Attached is screenshot of my action

 

Here's to hoping somone knows a thing or to about this api.

 

Alos I should mention that this error did not occer when running a defuault photoshop action.

TOPICS
Actions and scripting

Views

86

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 , Aug 04, 2021 Aug 04, 2021
psApp.DoAction('Action Folder', 'Action') ExtendScript DOM uses the reverse order of the arguments. If I understand correctly, then python interacts with the DOM through win32com.  psApp.DoAction('Action', 'Action Folder')

Likes

Translate

Translate
Explorer ,
Aug 04, 2021 Aug 04, 2021

Copy link to clipboard

Copied

Pardon my terrible typing. I'd like to fix my mistakes but i can't find a edit option.

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
Explorer ,
Aug 04, 2021 Aug 04, 2021

Copy link to clipboard

Copied

Sothing else I probably need to mention. Running the action through photoshop works fine. It's when I run it via python that I get the error.

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 ,
Aug 04, 2021 Aug 04, 2021

Copy link to clipboard

Copied

 

psApp.DoAction('Action Folder', 'Action')

 

ExtendScript DOM uses the reverse order of the arguments. If I understand correctly, then python interacts with the DOM through win32com. 

 

psApp.DoAction('Action', 'Action Folder')

 

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
Explorer ,
Aug 04, 2021 Aug 04, 2021

Copy link to clipboard

Copied

LATEST

I could kiss you

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