質問

I've just about finished an ExtendScript project for Adobe InDesign CS6. One of the last few bugs I need to squash comes in the form of this error message:

Cannot handle request because a modal dialog or alert is active

What happens in the script is that it opens an InDesign file, does some work to it, then saves and closes it. However, if the file has some text that uses a font which is not installed on my system, then a window pops up alerting me to that fact. Because of this popup window, the entire script is interrupted and errors out with the above message.

Is there any way for the script to handle this? Perhaps to keep an eye out for a popup window and just dismiss it (by doing the equivalent of clicking "OK" on the window) before it continues on with the rest of the script?

役に立ちましたか?

解決

Try this:

var oldUserInteractionLevel = app.scriptPreferences.userInteractionLevel;
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
// Put code here that would create the alert.
// E.g. If the alert is caused by opening the document, then open the document here.
app.scriptPreferences.userInteractionLevel = oldUserInteractionLevel;
// After this line you can safely show dialogues to the user.
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top