Adobe 23101764 Scripting Guide - Page 39
Your first Photoshop script
UPC - 718659340025
View all Adobe 23101764 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 39 highlights
Scripting Photoshop 3 Your first Photoshop script If you hold down the option key (alt for Windows), a debug window displays. NOTE: The "File>Scripts" menu displays JavaScripts only. 3.3 Your first Photoshop script The traditional first project in any programming language is to display the message "Hello World!" In this section, we'll create a new Photoshop document, then add a text item containing this message with examples in AppleScript, Visual Basic, VBScript and JavaScript. 3.3.1 AppleScript 1. Locate and open the Script Editor. 2. Below we're going to revisit the "Hello, World!" AppleScript example from Chapter 2 with comments included. (We'll expand on this sample code in the Advanced Scripting section that follows. ) For now, enter the following script. The lines preceded by "--" are comments. They're included to document the operation of the script and it's good style to include them in your own scripts. As you look through the script, you'll see how to create, then address, each object. The AppleScript command tell indicates the object that will receive the next message we send. -- Sample script to create a new text item and change its -- contents. tell application "Adobe Photoshop CS" -- Create a new document and art layer. set docRef to make new document with properties ¬ {width:3 as inches, height:2 as inches} set artLayerRef to make new art layer in docRef -- Change the art layer to be a text layer. set kind of artLayerRef to text layer -- Get a reference to the text object and set its contents. set contents of text object of artLayerRef to "Hello, World!" end tell 3. Run the script. Photoshop will create a new document, add a new art layer, change the art layer's type to text and set the text to "Hello, World!" Photoshop CS Scripting Guide 35