Your First Photoshop Script - Adobe 23101764 - Photoshop CS - PC Manual

Scripting guide
Hide thumbs Also See for 23101764 - Photoshop CS - PC:
Table of Contents

Advertisement

If you hold down the option key (alt for Windows), a debug window displays.
N
O T E
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.
-- Change the art layer to be a text layer.
-- Get a reference to the text object and set its contents.
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
The "File>Scripts" menu displays JavaScripts only.
:
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
set kind of artLayerRef to text layer
set contents of text object of artLayerRef to "Hello, World!"
Scripting Photoshop
Your first Photoshop script
3
35

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs

Table of Contents