Hiding Error Dialogs

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

photoshopscripter

Hiding Error Dialogs

Post by photoshopscripter »

Hi.

I've written a Photoshop script that we plan on using on close to 2000 PSD's. It automates everything, except for one issue that I just can't find a solution to. Some PSD's give errors that I can't suppress using a script. The only thing we can do is click OK when required. For example:

"This file uses an unsupported blending mode. Substitute normal mode?" => OK, Cancel, Read composite data

These errors happen in random PSD's (they came from various contractors that we hired over the years) so we have no idea which will throw an error and which won't. This means our automated script is only automated until an error occurs.

Is it possible to hide ALL errors and have it default to pressing the OK button?

Thanks!

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

pfaffenbichler

Hiding Error Dialogs

Post by pfaffenbichler »

"This file uses an unsupported blending mode. Substitute normal mode?"
This would seem to indicate that you work with an obsolete version of Photoshop and your contractor/s worked with more recent versions.
What’s your version?
Which editing steps do you perform on the images with the Script?
photoshopscripter

Hiding Error Dialogs

Post by photoshopscripter »

I'm using CS4 while they are likely to be using something later. Unfortunately we can't upgrade to a later version at the moment which is why I would like to remove the error dialogs entirely.

The only thing that is being done to the images is a layer is being removed (watermark layer that we've applied to each image) and replaced with a different one.
pfaffenbichler

Hiding Error Dialogs

Post by pfaffenbichler »

Sorry, no method to suppress such a dialog comes to my mind. (I could not test with the new Blend Modes as I don’t have CS4 installed here, but the Stroke that’s been added for Shape Layers in CS6 should, I think, function similarly when opening in CS5.)

Opening the flattened image is not an option if you need to remove a Layer. 
Hopefully someone else knows better.
photoshopscripter

Hiding Error Dialogs

Post by photoshopscripter »

The errors we get aren't always the one listed (sometimes fonts, sometimes other problems), so if anyone else knows of any way around it, I would love to know how
larsen67

Hiding Error Dialogs

Post by larsen67 »

Using AppleScript is the only way I have been able to catch this in the past… There were calls to change PS open behaviour but that wont affect older versions anyhows…
photoshopscripter

Hiding Error Dialogs

Post by photoshopscripter »

Unfortunately I'm on a Windows machine so I don't have access to AppleScript

It's starting to sound like one of those impossible tasks, which is unusual considering how powerful Photoshop's scripting capabilities are.
Mike Hale

Hiding Error Dialogs

Post by Mike Hale »

It is impossible for a Photoshop javascript to handle these kinds of error dialogs because it has to run with Photoshop as the host app.

But you should be able to find a small Windows OS app or utility that can dismiss the dialog from outside Photoshop. Handling dialogs that interfere with automating tasks is not limited to Photoshop.

Years ago I had something that would check to see if a window/dialog was open every few minutes and if found close it. Sorry I don't recall the name of the utility.
photoshopscripter

Hiding Error Dialogs

Post by photoshopscripter »

I was thinking that was what I had to do. I was just hoping Photoshop had that functionality.

I used to use a program called "Push The Freakin' Button" (now PTFB Pro) which should do it, so I guess that's what I'll use.

Thanks for the help everyone!
Paul MR

Hiding Error Dialogs

Post by Paul MR »

I have had a go with C# to monitor the Photoshop CPU usage.

I found that if there was modal window it needed more that just enter sending to the application, as when Photoshop is braught to the front the modal window was not in focus and it needed selecting with the mouse.
So the following does a check to see if Photoshop CPU usage is zero the checks a few seconds later, if it still zero Photoshop is selected, the mouse cursor it moved to the center of the screen and left mouse click simulated to bring focus to the window then an Enter is sent. I use File - File Info and Panel Options in the Layers Palette to do the testing.
Maybe it could work for you?
It's a console app and will terminate with ether control/c or if Photoshop is closed.

Code: Select allusing System;
using System.Diagnostics;
using System.Threading;
using System.Collections;
using System.Windows.Forms;
using System.Runtime.InteropServices;
/*
References
----------
system
System.Core
System.Data
System.Drawing
System.Windows.Forms
 */
namespace PhotoshopMonitor
{
public class Driver
{
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("User32")]
public static extern int SetForegroundWindow(IntPtr hwnd);
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);

private const int MOUSEEVENTF_ABSOLUTE = 0x8000;
    private const int MOUSEEVENTF_LEFTDOWN = 0x0002;
    private const int MOUSEEVENTF_LEFTUP = 0x0004;
    private const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;
    private const int MOUSEEVENTF_MIDDLEUP = 0x0040;
    private const int MOUSEEVENTF_MOVE = 0x0001;
    private const int MOUSEEVENTF_RIGHTDOWN = 0x0008;
    private const int MOUSEEVENTF_RIGHTUP = 0x0010;
    private const int MOUSEEVENTF_WHEEL = 0x0800;
    private const int MOUSEEVENTF_XDOWN = 0x0080;
    private const int MOUSEEVENTF_XUP = 0x0100;

        static void Main(string[] args)
        {
            killProcess();
        }

        private static void killProcess()
        {
            Console.WriteLine("Monitoring Photoshop CPU usage...\n\rControl/c to exit");
            int intInterval = 2500;
            string procName = "Photoshop";

            while (true)
            {
                Process[] pname = Process.GetProcessesByName("Photoshop");
                if (pname.Length == 0) break;

                Process[] runningNow = Process.GetProcesses();
                foreach (Process process in runningNow)
                {
                    using (PerformanceCounter pcProcess = new PerformanceCounter("Process", "% Processor Time", process.ProcessName))
                    {
                        if (process.ProcessName == procName)
                        {
                            pcProcess.NextValue();
                            System.Threading.Thread.Sleep(intInterval);
                           
                           // Console.WriteLine("Process:{0} CPU% {1}", process.ProcessName, pcProcess.NextValue());
                            //if Photoshop CPU has been idle for 5 seconds
                            //Center mouse, send a left mouse click then an enter.
                            IntPtr iHandle = FindWindow("Photoshop", null);

                            if (pcProcess.NextValue() == float.Parse("0"))
                            {       
                                SetForegroundWindow(iHandle);
                                Cursor.Position = new System.Drawing.Point(Screen.PrimaryScreen.Bounds.Width / 2,
                            Screen.PrimaryScreen.Bounds.Height / 2);
                                uint X = (uint)Cursor.Position.X;
                                uint Y = (uint)Cursor.Position.Y;
                                mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
                                SendKeys.SendWait("{ENTER}");
                                // return;

                            }
                        }
                    }
                }

                // Sleep till the next loop
                Thread.Sleep(intInterval);

            }

        }

    }

}




If you want to try just the binary..