Copy link to clipboard
Copied
How can I stop alerts from stopping my batch script?
I've found and adapted a script to do batch photomerges on a group photos that might be related. There's only one issue: Some of them aren't, and the photomerge script throws an alert ("Some images could not be aligned") and stops dead until I dismiss the dialog. That's...not automation. I tried to tell it to not display dialogs:
displayDialogs = DialogModes.NO;
alert('displayDialogs='+displayDialogs);
But that just doesn't work. (When you think about it, the second line shouldn't throw the alert telling me the value of displayDialogs, but it does).
I've tried various incantations:
app.displayDialogs
photomerge.displayDialogs
I've even put the DialogModes.NO into the photomerge script itself, but to no avail.
I guess I can perform surgery on the photomerge.jsx script itself, but all the documentation says that displayDialogs should work. I'm back on Photoshop CS6.
I also tried:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract
but this appears to be for a different version, as it complains that UserInteractionLevels is undefined.
I am using python to open the com object and then:
object.DoJavaScriptFile("/N/Images/panoramas/photomerger.jsx", ["a", "b"])
photomerger.jsx starts:
var runphotomergeFromScript = true;
#include "/C/Program Files/Adobe/Adobe Photoshop CS6 (64 Bit)/Presets/Scripts/Photomerge.jsx"
displayDialogs = DialogModes.NO;
alert('displayDialogs='+displayDialogs);
...
photomerge.createPanorama(jpg_list, false);
I even tried to figure out how to override alert(), but I couldn't get that to work either.
Any ideas before I hack up the script?
Thanks!
If that is what you're asking for cannot you just comment alert in your script like this (Photoshop CS6 EXTENDED / line 461):
//alert(localize("$$$/AdobePlugin/Shared/Photomerge/alignbad=Some images could not be automatically aligned"));
Copy link to clipboard
Copied
If that is what you're asking for cannot you just comment alert in your script like this (Photoshop CS6 EXTENDED / line 461):
//alert(localize("$$$/AdobePlugin/Shared/Photomerge/alignbad=Some images could not be automatically aligned"));
Copy link to clipboard
Copied
Thanks! Yes, my backup plan is to make a copy of the script and go in and rip out all of the alerts...or well, make the error returns that I could catch. But I would prefer to have a generic automation solution.
Copy link to clipboard
Copied
a()
function a()
{
function alert() {}
/////////// your main code start
var runphotomergeFromScript = true;
#include "/C/Program Files/Adobe/Adobe Photoshop CS6 (64 Bit)/Presets/Scripts/Photomerge.jsx"
displayDialogs = DialogModes.NO;
alert('displayDialogs='+displayDialogs);
///...
photomerge.createPanorama(jpg_list, false);
/////////// your main code end
}
Copy link to clipboard
Copied
This only works in the outer level: It suppresses the
alert('foo');
but the alert in photomerge script still fires.
So I guess I could modify the photomerge script itself with this: It would be easier than changing all of the alerts themselves!
(I've tried for literally the last 90 minutes to set my preferences and/or see the thing that let's me paste code, but all I get is some stupid "We could not complete your request. Please check the form for details.", so...my apologies for the ugly post):
do_merge()
function do_merge() {
function alert() {}
displayDialogs = DialogModes.NO;
alert('foo')
photomerge.createPanorama(jpg_list, false);
Copy link to clipboard
Copied
So in the end, I edited the Adobe script and changed all of the alert() calls to throw(), which I catch and then cleanup the active document. I guess that makes Kukurykus' answer the most correct...
Thanks for the help!