Is it possible to script photoshop to ignore dialog boxes/errors?

Hi,

I have a script that receives images from a camera and then sends them off to photoshop and runs through some actions and saves the resulting files to various places and prints.

In general this works fine but every now and again one of the files gets damaged/corrupted. This could be due to the camera, the computer, the lead, heat, law of averages etc so I don’t seem to be able to stop it. The problem is that when photoshop receives this corrupted file it displays a dialog box informing me and asking wether to continue or cancel. When this happens it stops the script which causes all sorts of problems in my automated system and means I have to keep checking.

Is there anything I can add to the script which will tell it to ignore photoshop dialog boxes/error and continue? - I would rather accept the odd dodgy file and continue.
Or even some sort of way of telling it to simulate clicking continue in the box if it appears?

Any thoughts most appreciated,
Thanks,
JM.

Hi Jeanmichel,

I am not doing a lot of Photoshop scripting, but looking at its AppleScript dictionary I can see that it supports a «display dialogs»-command, which controls whether or not Photoshop displays dialogs. The following properties can be used: always, error, dialogs or never.

So I would try to add the following line to the beginning of your Photoshop script:


tell application "Adobe Photoshop CS"
	set display dialogs to never
end tell

Maybe this will solve your problems.

Not 100% but I think this will ignore all app dialogs except an error on opening message box. Most common error is due to Photoshop being very fussy over JPEG markers being missing/misplaced.

Thanks guys,

Yep, this doesn’t ignore error on opening files messages which is the problem I’ve got.
Trying to figure out a way of automating the action of me clicking continue in this message box.

Oh well…

G’day

I struck the same problem, which seems to have been fixed by this routine

I’m interested in if it works or not, please.



tell application "Adobe Photoshop CS3"
				try
					activate
					open theItem as alias
					tell application "System Events" to tell process "Adobe Photoshop CS3"
						keystroke return
						keystroke return
						keystroke "p" using command down
						delay 2
						tell window "Print"
							keystroke return
							delay 0.4
							keystroke return
							delay 0.4
							keystroke return
						end tell
					end tell
					close document 1 saving no
					close document 1 saving no
					delay 1
				end try
			end tell

Model: intel 24" iMac
Browser: Safari 525.20
Operating System: Mac OS X (10.5)

Something like this may work for you. Sorry don’t have enough time to write the errors to a text file just at the minute.
Keystroking the dialog is OK but then I would want some sort of log of the events. PS_Info is the Photoshop error message text.

property Error_Report : (path to desktop folder as Unicode text) & "Problem Image Report.txt"
property PS_Info : ""
--
set The_File to choose file
--
tell application "Adobe Photoshop CS2"
	set notifiers enabled to false
	set User_Rulers to ruler units of settings
	set ruler units of settings to pixel units
	set foreground color to {class:RGB color, red:0.0, green:0.0, blue:0.0}
	set background color to {class:RGB color, red:255.0, green:255.0, blue:255.0}
	set display dialogs to never
end tell
--
tell application "Adobe Photoshop CS2"
	activate
	try
		with timeout of 2 seconds
			open The_File
		end timeout
	on error
		my Check_For_Dialogs()
		tell application "System Events"
			tell application process "Adobe Photoshop CS2"
				keystroke return
			end tell
		end tell
	end try
	set Doc_Ref to the current document
	tell Doc_Ref
		-- do your stuff here.
	end tell
end tell
PS_Info
--
on Check_For_Dialogs()
	tell application "System Events"
		if UI elements enabled then
			tell window 1 of application process "Adobe Photoshop CS2"
				if title = "Adobe Photoshop" then set PS_Info to value of static text 2
			end tell
		else
			tell application "System Preferences"
				activate
				set current pane to pane "com.apple.preference.universalaccess"
				display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
			end tell
		end if
	end tell
	return PS_Info
end Check_For_Dialogs

I haven’t got any corrupted image files around but…

If it is corrupted then can Image Events open it?

If it can’t then you could write a script that checks the entire folder corrupted images first and then moves them to a different folder


try
tell application "Image Events"
			launch
			set this_image to open this_item
end tell

on error
tell application "Finder"
		move every item of this_image to pathtomoveto
	end tell
end try


I’ve found that in most cases Graphic converter with throw up no problems at all with images that Photoshop does not like. Opening and saving problem files with this first then processing with Photoshop would be my workaround. BTW I made my duff file by just hacking out a chunk of data from a JPEG using Text Edit as I had no missing marker files to test with either.