Home / Articles / Adobe Creative Suite / Behind the Curtain: Scripting in Creative Suite

Behind the Curtain: Scripting in Creative Suite

Chapter Description

In this sample chapter, author Rick Ralston describes the benefits of scripting in Adobe's Creative Suite, describes the scripting tools and how to use them, and takes you through a simple script to get you started.
  • Trust that little voice in your head that says, "Wouldn't it be interesting if?" And then do it.
  • Photographer Duane Michals

Do you remember the scene in The Wizard of Oz in which Toto pulls back the curtain to reveal the man/wizard operating levers behind it? As a kid, what caught my attention wasn't the revelation or the treachery of the man; it was those levers. They were the tickets to doing wonderful wizardish things. If only I knew how to move those levers, I could escape all the indignities of childhood, I thought. Pull this one, push that one, and the world would be my marionette—a seductive idea for a kid. And to tell you the truth, I didn't even care about how the levers were operated. What mattered to me was knowing that they existed and where they were. Naturally, I assumed, there was a manual tucked away somewhere.

If you could peel back the interface of a Creative Suite program, as if sweeping aside curtains, you would see little packets of instructions zipping all over the place. These packets are Creative Suite's invisible levers. When you click a button in the interface, for instance, behind the curtain a command is shot to its target. What you see on the screen of a program is its graphical user interface (GUI), which consists of the file you're working on, panels, dialog boxes, and the informational windows that are occasionally presented to the user. All of this appears onscreen for our benefit—both to collect information from us and to provide feedback about what the program is up to.

We use this GUI to communicate with the program and it with us. However, we humans—even after a couple of cups of coffee—are a relatively slow and distractible lot, so the process can be less than efficient. It involves perceiving what's onscreen, making decisions based on those perceptions, and then applying hand-eye coordination to move the mouse and press the keys. Think of the time it takes (and the dialogs you have to wade through) just to launch a program, find and open a document, locate and edit text, replace a photograph, and then save and close the document.

What if instead all you had to do was send the program a simple message stating something like the following: "Open the program; open that file; change this text; replace that picture; and then save and close"? There'd be no clicking of icons or buttons, no reading and responding to dialog boxes, no navigating the document, and no keystrokes.

Sending a program messages in this way is hundreds of times faster than manually performing the described steps. These messages can "think" and make decisions on the fly just like we do, only faster and with far more accuracy. What's more, such messages can be modular (with parts reused in other messages), and they can be sent based upon certain circumstances—meaning you don't even have to be there to trigger them.

What Is Scripting Really?

Write down the steps you take to do something—feed the cat, do the laundry, check e-mail, anything. Include every little step. Then edit your words down to a set of bare-bones statements: Do this; make that decision; take that action. What you're left with will look surprisingly similar to a script. Providing a kind of shorthand, or to-do list of what it takes to complete a task or series of tasks (a workflow), scripts can be used to control existing applications.

The main difference between programming and scripting is that programming is used to create applications, while scripting is used to control them. Since the Macintosh and Windows operating systems are, in fact, applications, you can use scripting to control them as well.

Now, let's revisit the hypothetical example of feeding the cat: You go to the pantry to get the cat food. If there isn't any, then you go to the store to buy some more. Otherwise, you proceed to put the food in the bowl. That's logic: If this, then that. Although other forms of logic exist, the if/then statement is the type most often used in scripting. Logic provides a means of distilling your thought processes so that you can turn your scripts into "mini-yous," applying the decisions you would make—only a lot faster and far more accurately.

2. Why Would You Want to Script? | Next Section