Adobe 65009333 Scripting Guide - Page 23
Running scripts at start-up, Session and main script execution
UPC - 883919155852
View all Adobe 65009333 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 23 highlights
Scripting Features Running scripts at start-up 23 var myJavaScript = "app.scriptArgs.setValue(\"ScriptArgumentA\", \"This is the first script argument value.\");\r"; myJavaScript += "app.scriptArgs.setValue(\"ScriptArgumentB\", \"This is the second script argument value.\")"; var myScriptArgumentA = app.scriptArgs.getValue("ScriptArgumentA"); var myScriptArgumentB = app.scriptArgs.getValue("ScriptArgumentB"); alert("ScriptArgumentA: " + myScriptArgumentA + "\rScriptArgumentB: " + myScriptArgumentB); if(File.fs == "Windows"){ var myVBScript = "Set myInCopy = CreateObject(\"InCopy.Application.CS4\")\r"; myVBScript += "myInCopy.ScriptArgs.SetValue \"ScriptArgumentA\", \"This is the first script argument value.\"\r"; myVBScript += "myInCopy.ScriptArgs.SetValue \"ScriptArgumentB\", \"This is the second script argument value.\""; app.doScript(myVBScript, ScriptLanguage.visualBasic); } else{ var myAppleScript = "tell application \"Adobe InCopy CS4\"\r"; myAppleScript += "make script arg with properties{name:\"ScriptArgumentA\", value:\"This is the first script argument value.\"}\r"; myAppleScript += "make script arg with properties{name:\"ScriptArgumentB\", value:\"This is the second script argument value.\"}\r"; myAppleScript += "end tell\r"; app.doScript(myAppleScript, ScriptLanguage.applescriptLanguage); } var myScriptArgumentA = app.scriptArgs.getValue("ScriptArgumentA"); var myScriptArgumentB = app.scriptArgs.getValue("ScriptArgumentB"); alert("ScriptArgumentA: " + myScriptArgumentA + "\rScriptArgumentB: " + myScriptArgumentB); Running scripts at start-up To run a script when InCopy starts, put the script in the Startup Scripts folder in the Scripts folder (for more information, see "Installing scripts" on page 7). NOTE: Scripts run in the session ExtendScript engine when InCopy starts can create objects and functions that will be available to other scripts for the duration of the session. For more information, see "Session and main script execution" on page 23. Session and main script execution InCopy has two ways to run a JavaScript: session and main. These names correspond to the ExtendScript "engine" used to run the script. By default, when you run an InCopy JavaScript, the script is interpreted and executed by the "main" ExtendScript engine, which is destroyed when the script completes execution. Script objects created by the script do not persist. Scripts run in the session engine can create objects that persist until you close InCopy. You can refer to these objects from other scripts run in the session engine. To set the session engine as the target of an InCopy JavaScript, add the following line to the start of your script. #targetengine "session"