How to avoid modal dialogs from blocking script execution
Copy link to clipboard
Copied
Is there a way to avoid this?
Copy link to clipboard
Copied
app.scriptPreferences.userInteractionLevel =
UserInteractionLevels.neverInteract;
It suppresses all dialogs. Be sure to add this line at the end of your script:
app.scriptPreferences.userInteractionLevel =
UserInteractionLevels.interactWithAll;
Or even better, use it in the catch phrase of a try-catch construction.
Peter
Copy link to clipboard
Copied
I had a script running fine called from a Windows service using doScript. All of a sudden it stopped working throwing the error "Cannot handle the request because a modal dialog or alert is active". I tried setting the userInteractionLevel as described here in the script with the same result. I tried setting the userInteractionLevel on the com object in my c# code with the same result. I even tried making a test script that just creates a new document. I ran it in the UI with no problem, but got the same result when trying to run it from the service. I even uninstalled and reinstalled CS5. I don't see an option in the CS5 com object to show the window when running a script. I'm out of ideas and very stuck. Can anyone help?
Copy link to clipboard
Copied
I know you said you already tried it, but I would try running the script with indesign open so you can see what the problem is. Dialogs can still apear, even after you say 0 interaction, it happenes. Maybe your script creates a file dialog or something?
Copy link to clipboard
Copied
Did that. No luck. I tried a test script whose entire code is below. It runs fine in the UI, but produces the same error when executed from COM.
var doc = app.documents.add( true, app.documentPresets.itemByName( "[Default]" ) );
I even did a bare metal reinstall of CS5.
The same script & C# invocation of it works fine on a server I'm using for testing.
Is there a way to call doScript from COM and have it show the window? I believe there used to be in CS3.
Copy link to clipboard
Copied
In case anyone else experiences this, I hope to save you the week of pain it caused me. It turns out the dialog was about recovering a document. The only was I could get past it was a trick our IT guy figured out. He showed me how to run Windows as the System user. Once I did that, I was able to run InDesign as the System user and manually dismiss the dialog.
Here's how to do it in XP: http://alieneyes.wordpress.com/2006/10/23/how-to-gain-access-to-system-account-the-most-powerful-acc...
Here's what our IT guy figured out for Vista/Win7:
- Download and install PSTools from Microsoft: http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx
Launch cmd.exe as administrator
Run psexec -i -s c:\windows\system32\cmd.exe
Kill explorer.exe
In new command window type explorer.exe
Happy trails
Copy link to clipboard
Copied
Does not work in AE CC2017 - nothing like that exists there!
Copy link to clipboard
Copied
For anyone who comes across this looking for how to suppress errors in Photoshop CC, I found this worked:
app.displayDialogs = DialogModes.NO;
// Your code
app.displayDialogs = DialogModes.ERROR;

