AdobeInDesign.jsx脚本执行.jsx脚本

AdobeInDesign.jsx脚本执行.jsx脚本,adobe,adobe-indesign,extendscript,Adobe,Adobe Indesign,Extendscript,在执行完另一个.jsx脚本后,如何让我的.jsx脚本运行 也许这有助于理解我正在尝试做什么: // WebCard.jsx file function mySnippet(){ //<fragment> var myPageName, myFilePath, myFile; var myDocument = app.documents.item(0); var myBaseName = myDocument.name; for(var myC

在执行完另一个.jsx脚本后,如何让我的.jsx脚本运行

也许这有助于理解我正在尝试做什么:

// WebCard.jsx file

function mySnippet(){
    //<fragment>
    var myPageName, myFilePath, myFile;
    var myDocument = app.documents.item(0);
    var myBaseName = myDocument.name;
    for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
        myPageName = myDocument.pages.item(myCounter).name;
        app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
        app.jpegExportPreferences.resolution = 96;
       app.jpegExportPreferences.pageString = myPageName;  

          switch(myPageName) {
        case "1" : myPageName = "EN FRONT WebCard";
            docType = "Web/Web Cards" break;
        case "2" : myPageName = "EN BACK WebCard";
            docType = "Web/Web Cards" break;
        case "3" : myPageName = "ES FRONT WebCard";
            docType = "Web/Web Cards" break;
        case "4" : myPageName = "ES BACK WebCard";
            docType = "Web/Web Cards" break;

    }
        fileName = group + " " + myPageName + " " + date + ".jpg";

        myFilePath = dirPath + docType + "/" + fileName;
        myDocument.exportFile(ExportFormat.jpg, File(myFilePath), false);
    }
    //</fragment>
}
//</snippet>
                // execute PrintCard.jsx file


//<teardown>
function myTeardown(){
}
//</teardown>
//WebCard.jsx文件
函数mySnippet(){
//
变量myPageName、myFilePath、myFile;
var myDocument=app.documents.item(0);
var myBaseName=myDocument.name;
对于(var myCounter=0;myCounter
这里是我用来启动其他脚本的某个ExtendScript的片段;我在“后效”中使用过它,但在InDesign中可能也适用:

var theScriptFile = new File("/path/to/file.jsx");

var oldCurrentFolder = Folder.current;
Folder.current = theScriptFile.parent;

theScriptFile.open();
var theScriptContents = theScriptFile.read();
theScriptFile.close();

gCurrentScriptFile = theScriptFile;

if(doDebug)
    debugger;

// You have entered the debugger in Launcher...
// to debug the script you've launched, step
// into the eval() function below. 
//
eval( "{" + theScriptContents + "}" );

Folder.current = oldCurrentFolder;
gCurrentScriptFile = "";

方法是读取文件并对其进行评估。(另一个好的标记是ExtendScript,这里。)另请参见:

您可以轻松地包含另一个脚本,该脚本将在包含它的位置执行:

// ... Do something (will be executed before teardown script)


#include "../path/to/teardown/script.jsx" 
// the path can be absolute or relative.

这在从CS3向上的InDesign中应该可以使用。

我在阅读时遇到了一些问题,我将要启动的脚本放在哪里(PrintCard.jsx)?var theScriptFile=new File(“/absolute/path/to/PrintCard.jsx”);但是您可能需要绝对路径。。。adobe应用程序可能在相对路径方面表现不同;您必须尝试InDesign,看看是否可以创建新文件(“../PrintCard.jsx”)或类似文件;如果可能的话,尽量避免使用我认为的绝对路径。哈哈哈,我应该再读一遍,因为您声明:newfile(“/path/to/File.jsx”);--很抱歉…对我来说太好了!非常感谢。