
Photoshop CS3
Adobe Photoshop CS3 Scripting Guide Scripting Photoshop CS3 21
…
end tell
Note: Because you include all commands in the tell block, there is no need to reference the
Application object throughout the script.
VBS
In VBScript, do the following to target the application:
Dim appRef
Set appRef = CreateObject("Photoshop.Application")
JS
In JavaScript, because you do not need to reference an Application object, all properties and methods of
the application are accessible without any qualification. You can reference the application as part of the
containment hierarchy or leave it out, whichever makes your scripts easier for you to read.
To reference the
Application object, use the pre-defined global object app, rather than the class name.
The following statements are equivalent:
var docRef = app.documents[1]
and
var docRef=documents[1]
Note: Many JavaScript samples throughout this guide do not reference the Application object.
Creating New Objects in a Script
To create a new document in the Photoshop CS3 application, you select File > New. To create other types
of objects within a document, such as a layer, channel, or path, you use the Window menu or choose the
New icon on the appropriate palette. This section demonstrates how to accomplish these same tasks in a
script.
To create an object in a script, you name the type of object you want to create and then use the following
command:
● AS: make
● VBS: Add
● JS: add()
As you can see in the ‘Photoshop CS3 Object Model’ on page 9, the Document object contains all other
objects except the
Application, Notifier, and Preferences objects. Therefore, you must reference the
Document object when adding objects other than Document and Notifier objects to your script. (It is not
possible to add a new Preferences object.)
Note: In VBScript and JavaScript, you use the object’s collection name to name the object type. For
example, you add a document to the
Documents collection; you add an art layer to the art layers
collection. See Introduction to Scripting for more information on elements and collections.
AS
The following statement creates a Document object in an AppleScript.
make new document
You can also use the set command to create a variable to hold a reference to a new document. In the
following example, the variable named
docRef holds a reference to the new document: