1


     当文档没有任何模式对话框窗口消息时,  app.activeDocument.close(SaveOptions.no)  工作正常。

     但是,我有一些 InDesign 文档确实出现了此类窗口,显示有关需要更新的链接或样式不正确的错误消息。上面的语句在这种情况下不起作用,因为窗口阻止脚本访问文档。


     那么,有没有办法遍历活动文档中的所有模式对话框?这是我迄今为止尝试过的,但不起作用

if(xmlFile == "")
{
    //alert("There is no linked XML file in this document,\n\ttry a different document.");

    for(var i = 0; i < app.activeDocument.Windows.length; i++)
    {
        app.activeDocument.Windows[i].close();
    }

    app.activeDocument.close(SaveOptions.no);
    exit();
}
4

2 回答 2

4

好的,所以需要将应用程序的“用户交互级别”更改为“ NEVER_INTERACT”以忽略所有模态对话框窗口。这是修改后的代码,现在可以使用:

if(xmlFile == "")
{
    alert("There is no linked XML file in this document,\n\ttry a different document.");

     // the original interaction and warning settings of the application
    var oldInteractionPrefs = app.scriptPreferences.userInteractionLevel;

    // prevent interaction and warnings from interrupting script
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

    // close the active document without saving
    app.activeDocument.close(SaveOptions.no);

    // reset interactions to original settings
    app.scriptPreferences.userInteractionLevel = oldInteractionPrefs;

    exit();
}
于 2012-08-02T18:58:49.190 回答
1

你试过了吗?

app.activeDocument.windows.everyItem.close(SaveOptions.no);
于 2014-06-27T15:01:15.900 回答