Highlighted

C# Running Actions Command Play Currently Unavailable

Community Beginner ,
Aug 30, 2020

Copy link to clipboard

Copied

I have a C# project that I am attempting to Open Photoshop 2019, Run Auto Crop and Straighten on a Canon Raw Image, and save the output image as a TIFF.  I have a Action to perform those tasks.  Running the action in Photoshop works 100% of the time.

 

When attempting to run the action in a Visual Studio 2019 C# windows app.  I am referencing  Photoshop.DLL object library.  When I run "DoAction", I receive a

 

System.Runtime.InteropServices.COMException 

'General Photoshop error occurred. This functionality may not be available in this version of Photoshop.
- The command "Play" is not currently available.'

 

StackTrace " at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)\r\n at Photoshop._Application.DoAction(String Action, String From) .... etc etc.

 

I some success getting furhter in the process with Photoshop 2020 Type Library but it still wouldnt get through the Actions.

 

Any ideas what is causing this and any solutions? I would like to use 2020 if possible.

Topics

Actions and scripting, Problem or error, Windows

Views

129

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

C# Running Actions Command Play Currently Unavailable

Community Beginner ,
Aug 30, 2020

Copy link to clipboard

Copied

I have a C# project that I am attempting to Open Photoshop 2019, Run Auto Crop and Straighten on a Canon Raw Image, and save the output image as a TIFF.  I have a Action to perform those tasks.  Running the action in Photoshop works 100% of the time.

 

When attempting to run the action in a Visual Studio 2019 C# windows app.  I am referencing  Photoshop.DLL object library.  When I run "DoAction", I receive a

 

System.Runtime.InteropServices.COMException 

'General Photoshop error occurred. This functionality may not be available in this version of Photoshop.
- The command "Play" is not currently available.'

 

StackTrace " at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)\r\n at Photoshop._Application.DoAction(String Action, String From) .... etc etc.

 

I some success getting furhter in the process with Photoshop 2020 Type Library but it still wouldnt get through the Actions.

 

Any ideas what is causing this and any solutions? I would like to use 2020 if possible.

Topics

Actions and scripting, Problem or error, Windows

Views

130

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
Most Valuable Participant ,
Aug 30, 2020

Copy link to clipboard

Copied

Are you referring to Photoshop File>Automate>Crop and Straighten Photos?  If so why are you RAW file not straight? You photographing picture or pages of Text. Why doe you need toe creat a C# application. There  are Photoshop Scripts on the web to batch Crop and Straighten Photos cropAndStraightenBatch.jsx  An Action step Crop and Straighten Photo followed by a simple script step cabs casb and closed all the cripped images. That action can even be batched.

image.png

var outputFolder = "~/Desktop/outputFiles";					// Default output files folder
var makeFolder = new Folder(outputFolder);					// make sure the folder 
makeFolder.create();										// exists
app.documents[0].close(SaveOptions.DONOTSAVECHANGES);		// Close the Scan
for (var i=0;i<documents.length;i++) {						// Save the open new image documents
	activeDocument=documents[i];							// Switch Documents
	outputFile = outputFolder + "/" + activeDocument.name;	// Construct full output file path
	SaveAsJPEG( outputFile , 10 );							// Save Jpeg Quality 10 file
}
while (app.documents.length) {
	app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);	// Close the saved new document
}		
//////////////////////////////////////////////
function SaveAsJPEG(saveFile, jpegQuality){
	var doc = activeDocument;
	if (doc.bitsPerChannel != BitsPerChannelType.EIGHT) doc.bitsPerChannel = BitsPerChannelType.EIGHT;
	jpgSaveOptions = new JPEGSaveOptions();
	jpgSaveOptions.embedColorProfile = true;
	jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
	jpgSaveOptions.matte = MatteType.NONE;
	jpgSaveOptions.quality = jpegQuality;
	activeDocument.saveAs(File(saveFile+".jpg"), jpgSaveOptions, true,Extension.LOWERCASE);
}
JJMack

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
Reply
Loading...
Community Beginner ,
Aug 30, 2020

Copy link to clipboard

Copied

I am looking for a way to run an Action from C#.  If that means I have to run an Action is JSX and use C# to run the JSX file, thats fine too.

 

Re: your screen shot, thats exactly what I'm doing.  However, I've found that doing a batch is too slow. The preference is to do one at a time because as the action is running, the user is placing the next photo on the copy stand.  The action is always done before the user takes the next image so it saves a ton of time at the end of the process waiting on the batch.

 

There is a lot of other things that need to happen before and after the step
to data and "other data" things the image that necessitates a windows
application. Ie. After the image is saved, upload to a Box.com folder for backup.

This is not a case of a graphics designer “using” photoshop to batch images
otherwise all the actions work perfectly.  I wish that it was.

The other part of the application uses Image Processor Pro (Brown) to
perform some resizes and exports.

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
Reply
Loading...
Guide ,
Aug 30, 2020

Copy link to clipboard

Copied

Try this...

using System;


namespace Action_Test
{
    class Program
    {
        static void Main(string[] args)
        {
            dynamic app = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.Application"));
            runAction(app, "ActionName", "ActionSet");
        }
        static void runAction(dynamic app, string act, string set)
        {
            dynamic d = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.ActionDescriptor"));
            dynamic r = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.ActionReference"));
            r.PutName(app.StringIDToTypeID("action"), act);
            r.PutName(app.StringIDToTypeID("actionSet"), set);
            d.PutReference(app.StringIDToTypeID("null"), r);
            app.ExecuteAction(app.StringIDToTypeID("play"), d, 3);
        }

    }
}

 

 

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
Reply
Loading...
Most Valuable Participant ,
Aug 30, 2020

Copy link to clipboard

Copied

Perhaps your C# plug-in could run Photoshop plug-in CropPhotosAuto.8li then process the new documents created created for the current document eliminate running actions and scripts.

JJMack

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
Reply
Loading...
Community Beginner ,
Aug 30, 2020

Copy link to clipboard

Copied

SuperMerlin - thanks but I am still having the problem. 

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
Reply
Loading...
Community Beginner ,
Aug 31, 2020

Copy link to clipboard

Copied

Super Merlin - now that Ive changed the approach to the problem Im going to try your code again.

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
Reply
Loading...
Adobe Community Professional ,
Aug 30, 2020

Copy link to clipboard

Copied

Such an error (in scripts for sure) occurs if either the Action name or the ActionSet name is specified incorrectly.
Check the names, they are case sensitive. There should be no extra or missing spaces.
 

 

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
Reply
Loading...
Community Beginner ,
Aug 30, 2020

Copy link to clipboard

Copied

Thanks but I assume you that it is not in the scripts.  This issue is in C# between launching Photoshop and Preparing to run the script. 

 

It's not even getting to that step now.  It's failing before the openning of the cr2 raw image.

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
Reply
Loading...
Most Valuable Participant ,
Aug 30, 2020

Copy link to clipboard

Copied

Does Photoshop Plug-in ACR convert the CR2 file raw data and open a new Photoshop document for the cr2 file NO. Photoshop Does not support RAW files Its Plug ACR does.  IS ACR hanging?

JJMack

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
Reply
Loading...
Community Beginner ,
Aug 30, 2020

Copy link to clipboard

Copied

In my old version

  • The c# app opens the last Canon CR2 raw and loads straight into photoshop.  When loading through c# it doesnt load the traditional ACR as if I just double clicked a raw image.
  • The c# app runs AUTOCROP AND STRAIGHTEN + closes previous
  • c# determines number of active windows. If not 1, then something went wrong
  • C# app runs ACTIONS predetermined curves setting and exports a tiff.
  • Based on that tiff, C# app runs ACTIONS to resize, border and export to differnet folders
  • C# app renames outputed filed, applies meta data, and moves to them local backups and cloud locations.

The new version I'm creating I can't run through this process. In Photoshop 2020, I had to run actions using the PhotoshopTypeLibrary but that failed on export.

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
Reply
Loading...
Most Valuable Participant ,
Aug 30, 2020

Copy link to clipboard

Copied

Photoshop does not support RAW files it can not process RAW camera data.  Photoshop works with RGB images not mosaic camera images. ACR has to process Camera RAW data into an RGB image for photoshop even RAW file process by LR past to Photoshop for processing is open in photoshop via ACR. When I double click on a CR2 file in Windows File explored Photoshop is started and Photoshop Open the Raw file in ACR where I can adjust ACR settings and do local ACR editing of the image of the conversion in ACR.   ACR is a Photosjop Plug-in and a filter and its UI will changes with how ACR is started and ACR can  Bypass displaying it UI and use default settings or recorder ACR settinge to convert the RAW camera data. ACR UI does not always open when ACR is used. Still its ACR the opens the new document in Photoshop containing a Background layer or Smart Object layer.  If it is smart object  layer the object is is associated with the RAW file it is embedded or linked. If I place in a RAW file in a script. ACR UI will not open the Snart Object laye object  will still be associated the the RAW file and and the Smart Object Pixels the ACR conversion of the RAW data.

JJMack

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
Reply
Loading...
Community Beginner ,
Aug 30, 2020

Copy link to clipboard

Copied

In my iteration that works; it was compiled with VS2017, C#.NET 4.61 

It takes cr2 image and places it into a folder.

And here's where it gets interesting.  Photoshop is not doing the opening.  Using the dotPeek to look at my EXE (the source was lost). The cr2 is instead being opened by ImageProcessorPro (Brown) and saved to a JPG.  I still think that a bit odd but I am going to change some things around.

 

Capture.PNG

 

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
Reply
Loading...
Most Valuable Participant ,
Aug 31, 2020

Copy link to clipboard

Copied

Image Processor Pro is a Photoshop Plug-in script that you install into Photoshop versions Presets scripts.  X did not save it as JSXBIN so you can read the plug-in script to see if  did anything special to open RAW files in Photoshop.

 

As I wrote when I place in RAw file in a Photoshop Script ACR UI does not open ACR. ACR Just Creates the Smart object Layer in the current document..  When I open RAW file in a Photoshop Script ACR UI does not open a new Document opens in photoshop with the ACR conversion and is the Photoshop Active document. I do not do any special processing for the RAW files I just use Photoshop Place and Open. My script process RAW File and supported Image File types the same.  My scripts do not process Image file types the Photoshop doe not support like vector images svg, ai, esp, pdf. Files that Photoshop Imports I filter out.  RAW file are processed  by my script for I know Photoshop in New Photoshop docyment. Other none support image files types are imports as multiple documents or as a merged raster image. I do not process.  Photoshop is a Pixel Image editor not a file editor. It is not a vector editor it does not support some image file formats but came import some images from some none supported image file types.

JJMack

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
Reply
Loading...
Community Beginner ,
Aug 31, 2020

Copy link to clipboard

Copied

So I think I got this a little off topic.  The issue is from the c# app, photoshop opens and will not execute ANY action - forget the raw file and forget ACR.

 

Process[] pname = Process.GetProcessesByName("Photoshop");
if (!(pname.Length > 0))
{
try
{
Process p = new Process();
p.StartInfo.FileName = @"C:\Program Files\Adobe\Adobe Photoshop 2020\Photoshop.exe";
p.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Open Photoshop error");
}
}

Photoshop.Application PsA = new Photoshop.Application();
PsA.DisplayDialogs = PsDialogModes.psDisplayNoDialogs;
PsA.DoAction("MyTestAction", "MyActionsFolder");  // I fail here with that Interop error. This is a simple record action that opens a jpg and changes to black and white, saves, and closes.

 

Capture.PNG

 

 

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
Reply
Loading...
Guide ,
Aug 31, 2020

Copy link to clipboard

Copied

It looks as if the file is not open when you are trying to run the action.

You could try...

using System;
using ps = Photoshop;

namespace Action_Test
{
    class Program
    {
        static void Main(string[] args)
        {
            ps.Application app = new ps.ApplicationClass();
            String openfile = @"C:\Program Files\Adobe\Adobe Photoshop 2020\Photoshop.exe";
            app.Open(openfile);
            app.DoAction("MyTestAction", "MyActionsFolder");
        }
    }
}

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
Reply
Loading...
Community Beginner ,
Aug 31, 2020

Copy link to clipboard

Copied

Im having problems posting images here. 

 

Doing it exactly as you specified above, I get

Error CS1752 Interop type 'ApplicationClass' cannot be embedded. Use the applicable interface instead. 

 

Doing it as ps.Application app = new ps.Application(); //no class

I get the same Interop errors.

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
Reply
Loading...
Community Beginner ,
Aug 31, 2020

Copy link to clipboard

Copied

So this is odd...
Instead of opening the file as the first step in my Action Set, I opened the file programmatically via C#.

Yes, opening the RAW file loads straight into Photoshop without ACR.

But, I was still getting the error that the DoAction wouldnt work because play wasnt available.

 

Through some tinkering, I was able to add the PhotoshopTypeLibrary as a reference in Photoshop.  I was always getting errors that I couldn't add the TLB for a litany of reasons.

 

When I scrapped Photoshop.DoAction in favor of PhotoshopTypeLibrary.PlayAction , it sort of worked.  I'm going to play with this a bit more.  In the meantime, anyone have any insight into this?

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
Reply
Loading...
Community Beginner ,
Sep 14, 2020

Copy link to clipboard

Copied

The issue still isnt solved. IT can run all actions EXCEPT for ImageProcessorPro.  There has to be other people doing this without any issues.

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
Reply
Loading...