Copy link to clipboard
Copied
I've created a script which opens images in photoshop and then edits then. Everything has been working fine until I came across one this morning which produced the following message... "This document may be damaged (the file may be truncated or incomplete) continue?". When I manually clicked continue it opened the image and then continued.
Now, most of the time this script runs when I'm not at the computer and obviously the idea of scripting is to be automated so is there anyway to automatically "click" continue if this happens again?
Thanks for your help.
Copy link to clipboard
Copied
This can be done with AppleScript on the mac. May be possible with VB on the PC too? Outside the reach of ExtendScript unless you can call out to which ever of those other languages suits your OS…
Copy link to clipboard
Copied
How would it be done with AppleScript then? I'm currently using VBScript.
So if I use a try/catch block what would I need to add to get it to skip / "click" continue ? ...
Dim docRef
fileName = "C:\test.jpg"
Try
docRef = appRef.Open(fileName)
Catch ex As Exception
End Try
Thanks for your replies.
Copy link to clipboard
Copied
On Windows, I used an app called AutoHotKey, a keyboard macro program. I configured it to watch for the damaged file dialog from Photoshop and have it click the Continue button. This usually worked.
I was never able to get the equivalent AS script working but that may because I'm practically illiterate in AS. I don't recall anybody ever posting a working solution for OS X.
Copy link to clipboard
Copied
I don't need it to work in apple script. Ideally I'd like a solution in vbscript, it was just with Mark saying "This can be done with AppleScript on the mac", I was just interested to know roughly how it was done to see if I could do the same thing in vbscript.
So the only way to solve this then is with an external app?
I came across something similar last week. I can't remember the exact error message but when opening an image I think it said something along the lines of "there might be a problem with this file". BUT, in the error box it had a tick box saying "don't show this message again". When I clicked ok it again worked fine and because I'd ticked the box, when opening the same image the message never appeared again. I thought that would be the last time I saw a file error message but now I've come across this new one!
Thanks.
Copy link to clipboard
Copied
So the only way to solve this then is with an external app?
It's the only way I've been able to get this to work.
I thought that would be the last time I saw a file error message but now I've come across this new one!
Depending on how a file is corrupted, PS may throw a JS exception or put up this annoying dialog. If you got a dialog with a tick box, it would imply that there are some corruption modes that PS feels is OK for it to auto-correct when opening a file. I haven't seen it, BTW.
Copy link to clipboard
Copied
With AppleScript you can wrap the opening command inside of a 'timeout' block. Photoshop does NOT kick an error back but the timeout throws the error after a couple of seconds with that you command the keystroke.
try
with timeout of 2 seconds
open The_File
end timeout
on error
tell application "System Events"
tell application process "Adobe Photoshop CS2"
keystroke return
end tell
end tell
end try
I wouldn't know if there is any such method in VB? I could not get anything to work with calling out to app.system();
Copy link to clipboard
Copied
Mark, that sort of solution would be ideal.
Hopefully it will be possible to do the same thing with VB instead. I'll have to look into that.
Thanks.
Copy link to clipboard
Copied
From experience, you may want try different timeout values. Big PSD files can take a lot longer than 2 seconds depending on your rig.
Copy link to clipboard
Copied
@ xbytor2 - Don't suppose you know how to do the equivalent with a timeout in VB do you?
Thanks.
Copy link to clipboard
Copied
Sorry, no. I am also VB illiterate.
Copy link to clipboard
Copied
No problem, thanks anyway.
I think I'm going to look into the autohotkey solution instead then. I've downloaded the app and hopefully that will be more straight forward to just look out for that dialog box and click continue!
Thanks both for your help.
Copy link to clipboard
Copied
All sorted now with AutoHotKey 🙂
Copy link to clipboard
Copied
Just to see if this was possible via another method on OSX. I made an AppleScript app that I can launch before running an ESTK PS script. It's a bit doppy in it's response times (around 5-20 seconds Im not sure why that is)… but did work. I will see if I can re-word it and make it work any better…
on run
delay 1
end run
on idle
tell application "System Events"
try
set ps to the first process whose name contains "Photoshop"
if frontmost of ps is true then
tell window 1 of ps
if title is "Adobe Photoshop" then
tell ps to keystroke return
end if
end tell
end if
end try
end tell
end idle
Copy link to clipboard
Copied
You can wrap the app.open() call in a try/catch block which will let you skip some corrupted files but not all. This has been a known problem for many years.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now