• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

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

2.5K

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

Guide , 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')

 

Votes

Translate

Translate
Adobe
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.

Votes

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.

Votes

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
Guide ,
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')

 

Votes

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

I could kiss you

Votes

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
New Here ,
Apr 26, 2023 Apr 26, 2023

Copy link to clipboard

Copied

LATEST

It seems like you are having trouble running an action via Python in Photoshop. According to the error message you received, it seems like the 'play' command is not currently available. After doing some research, you found out that this error message can occur when some step in the action is not behaving as it should.

You have already tried deleting steps from the action to determine which step is causing the error, but even when you are only changing the image size, the error still occurs.

It's great that you are using an API to control Photoshop with Python, and I would recommend checking if the API is compatible with the version of Photoshop you are using. Additionally, you may want to try running the action manually in Photoshop to see if you can identify the step that is causing the error.

If you are interested in learning more about Java programming, you may want to check out this free course It covers the basics of Java programming and could be a helpful resource in your programming journey.

Votes

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