Skip to content

Instantly share code, notes, and snippets.

@smk
Forked from anonymous/gist:4540149
Last active October 26, 2016 11:42
Show Gist options
  • Save smk/4540163 to your computer and use it in GitHub Desktop.
Save smk/4540163 to your computer and use it in GitHub Desktop.
Controlling undo with doScript.
/**
* Controlling Undo with doScript
*
* InDesign gives you the ability to undo almost every action, but this comes at a price: for almost every
* action you make, InDesign writes to disk. For normal work you using the tools presented by the user
* interface, this does not present any problem. For scripts, which can perform thousands of actions in the
* time a human being can blink, the constant disk access can be a serious drag on performance.
* The doScript method offers a way around this performance bottleneck by providing two parameters that
* control the way that scripts are executed relative to InDesign’s Undo behavior. These parameters are
* shown in the following examples:
*/
//Given a script "myJavaScript" and an array of parameters "myParameters"...
app.doScript(myJavaScript, ScriptLanguage.javascript, myParameters, UndoModes.fastEntireScript, "Script Action");
//UndoModes can be:
//UndoModes.autoUnto: Add no events to the Undo queue.
//UndoModes.entireScript: Put a single event in the Undo queue.
//UndoModes.fastEntireScript: Put a single event in the Undo queue.
//UndoModes.scriptRequest: Undo each script action as a separate event.
//The last parameter is the text that appears in the Undo menu item.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment