Software Articles

February 25, 2011

InDesign Scripting With The ExtendScript Toolkit

Filed under: Computers — Tags: , , , , , — admin @ 12:55 am

ExtendScript is the Adobe implementation of JavaScript which is used to automate the Adobe Creative Suite. The ESTK is an ExtendScript editing utility which contains a number of useful features; however, there is nothing to stop you using your favourite code editor instead. The ESTK development environment now resembles a standard Adobe application with everything in its usual place; which makes it fairly easy to get used to.

Panels are docked on the right and are hidden or made visible by choosing their names from the Window menu. The arrows for Collapse to Icons and Expand Dock work as they do in the Creative Suite programs.

On the right of the menu bar is a drop-down menu containing preset workspace names which, when chosen, automatically rearrange the floating panels into a given configuration. If you come up with an arrangement of panels which you find ideal, you can save it by choosing Create New Workspace from the workspace drop-down menu in the top right of your screen.

The ESTK can display line numbers: an essential feature when working with programming code. This feature can be activated or deactivated by choosing View – Line Numbers or by using the keyboard shortcut: Control-Shift-L on Windows; Command-Shift-L on Mac.

It also offers the colour-coded highlighting of syntax, whereby the colour of words and statements confirms their role within the code: for example, JavaScript keywords are shown in blue and fixed text strings (inside quotation marks) in burgundy.

Another useful feature is Code Collapse whereby the program automatically displays buttons for hiding and revealing blocks of code. This feature simplifies navigation in longer scripts: you can temporarily hide lines as an alternative to constantly having to scroll past them to get to another part of your script. This feature can be activated and deactivated by choosing View – Code Collapse. The program automatically recognizes blocks of code and places a minus-sign icon at the start of each block. If you click on the minus-sign icon, the entire block is hidden and replaced by a horizontal line. The minus-sign icon then changes to a plus-sign. To reveal the hidden block once more, click on the plus-sign icon.

If you have used any of the Microsoft code-editing tools such as the Visual Basic Editor used to create macros in Microsoft Office, you will be familiar with the concept of intelliSense, whereby the code editor offers you a list of context-sensitive options as you enter keywords. By choosing an option from the list, you avoid making syntax errors and you don’t spend so much time looking things up. Adobe Dreamweaver offers a virtually identical feature called code hinting. The ESTK also has an auto completion feature. However, it falls far short of the equivalent features found in Dreamweaver and the Microsoft editors. When you type certain words, lists of suggestions do appear; but they are not very closely targeted to the code you are entering. However, when you are learning a new programming language, every little helps; so why not try it and see what you think. This feature is activated by default: if you wish to deactivate it, choose Edit – Preferences (Windows) or ExtendScript Toolkit – Preferences (Macintosh). Click on the Help category on the left of the Preferences dialog then uncheck the option Enable Auto Completion.

InDesign CS5 Automation Using XML and JavaScript by Grant Gamble

Powered by WordPress