Getting the Current Script. Adobe InDesign CS5
विज्ञापन
विज्ञापन
C HAPTER 2: Scripting Features Getting the Current Script 12
Property Description
UserInteractionLevel This property controls the alerts and dialogs InDesign presents to the user.
When you set this property to idUserInteractionLevels.idNeverInteract
, InDesign does not display any alerts or dialogs. Set it to idUserInteractionLevels.idInteractWithAlerts
to enable alerts but disable dialogs. Set it to idUserInteractionLevels.idInteractWithAll
to restore the normal display of alerts and dialogs. The ability to turn off alert displays is very useful when you are opening documents via script; often,
InDesign displays an alert for missing fonts or linked graphics files. To avoid this alert, set the user-interaction level to idUserInteractionLevels.idNeverInteract
before opening the document, then restore user interaction (set the property to idUserInteractionLevels.idInteractWithAll
) before completing script execution.
Version The version of the scripting environment in use. For more information, see
“Script Versioning” on page 12
. Note this property is not the same as the version of the application.
Getting the Current Script
You can get a reference to the current script using the
ActiveScript
property of the application object.
You can use this property to help you locate files and folders relative to the script, as shown in the following example (from the ActiveScript tutorial script):
Set myInDesign = CreateObject("InDesign.Application") myActiveScript = myInDesign.ActiveScript
MsgBox ("The current script is: " & myActiveScript)
Set myFileSystemObject = CreateObject("Scripting.FileSystemObject") myParentFolder = myFileSystemObject.GetFile(myActiveScript).ParentFolder
MsgBox ("The folder containing the active script is: " & myParentFolder)
When you debug scripts using a script editor, the
ActiveScript
property returns an error. Only scripts run from the Scripts palette appear in the ActiveScript property.
Script Versioning
InDesign CS5 can run scripts using earlier versions of the InDesign scripting object model. To run an older script in a newer version of InDesign, you must consider the following:
X Targeting — Scripts must be targeted to the version of the application in which they are being run
(i.e., the current version). The mechanics of targeting are language specific.
X Compilation — This involves mapping the names in the script to the underlying script ids, which are what the application understands. The mechanics of compilation are language specific.
X Interpretation — This involves matching the ids to the appropriate request handler within the application. InDesign CS5 correctly interprets a script written for an earlier version of the scripting object model. To do this, run the script from a folder in the Scripts panel folder named
Version 5.0
Scripts (for InDesign CS3 scripts) or Version 2.0
Scripts (for InDesign CS2 scripts), or explicitly set
डाउनलोड
विज्ञापन