How Scripting Works

If you intend to write your own script code from scratch, you need to know how to use a script to select an object and do something to it. In the programming world, the rules by which you do that are known as the object model. The scripting object model for Photoshop is hierarchical, like the folders on Web sites and your hard drive. When you want to open a specific Web page, you specify a URL that digs through the Web site (as in, a top-level folder (, and more specific folders until you get to the file you want to view ( In Photoshop, your script must identify the application (Photoshop), the document, and the type of object you intend to change, such as a layer, a selection, or a history state.

Once your script identifies the object, you can use a scripting command (AppleScript) or method (JavaScript and VBScript) to change the properties of an object. This is like selecting a layer and changing the values in a dialog box or palette.

A script can also define variables, placeholders that store a value that can change as the script runs. A variable can change because the script performs a calculation on it, or because Photoshop replaces the variable with values you enter or from an external file. For example, in the business card example at the beginning of this chapter, a Photoshop script could start with a blank business card document, duplicate the business card to fill a page, and populate each card with a different employee name read from a text file.

You can see more details about the Photoshop object model in the Adobe Photoshop CS2 Scripting Guide (see the section "Scripting Resources").

Working Smart in Adobe Photoshop CS2
Working Smart in Adobe Photoshop CS2
ISBN: 0321335392
EAN: 2147483647
Year: N/A
Pages: 161
Authors: Conrad Chavez © 2008-2017.
If you may any questions please contact us: