InDesign CS5脚本:如何关闭文档中的所有模式对话框窗口? [英] InDesign CS5 Script: How can I close all modal dialog windows in a document?

查看:296
本文介绍了InDesign CS5脚本:如何关闭文档中的所有模式对话框窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


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

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


    那么,有没有办法遍历活动文档中的所有模态对话框?到目前为止,这是我尝试过的,正常工作:


     When a document does not have any modal dialog window messages,  app.activeDocument.close(SaveOptions.no)  works fine.

     However, I have some InDesign documents that do have such windows appear, showing error messages about links that need to be updated, or incorrect styles. The above statement won't work in this case, as the windows prevent the script from accessing the document.


     So, is there a way to iterate through all of the modal-dialogs in the active document? Here is what I have tried so far, which is not working:

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();
}

推荐答案

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

Ok, so the "user interaction level" of the application needs to be changed to "NEVER_INTERACT" to ignore all modal dialog windows. Here is the modified code, which is now working:

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();
}

这篇关于InDesign CS5脚本:如何关闭文档中的所有模式对话框窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆