Photoshop CS2
Adobe Photoshop CS2 Scripting Guide
Scripting basics 13
Some commands require additional data. In AppleScript, the
make new
command adds a new object. You
can specify properties for the object by enclosing the properties in brackets and preceding the brackets
with the phrase
with properties
. The following statement creates a new document that is four inches wide
and two inches high.
make new document with properties {width:4 as inches, height:2 as inches}
Note:
See
‘Setting the Active Object’ on page 39
for information on making sure your script
performs the task on the correct object.
Methods and Arguments
You insert methods at the end of a VBScript or JavaScript statement. You must place a period before the
method name to separate it from the rest of the statement.
The following VBScript statement prints the current document:
appRef.Documents(1).PrintOut
A method in JavaScript must be followed by parentheses, as in the following statement:
app.documents[0].print()
Some methods require additional data, called
arguments
, within the parentheses. Other methods have
optional arguments. The following statements use the
Add/add()
method to add a bitmap document
named
myDocument
that is 4000 pixels wide and 5000 pixels tall and has a resolution of 72 pixels per inch:
Note:
Even though the
Document
object in the following script statements is given a name
(
myDocument
), you use the object collection name when you add the object. See
‘Referring to
an Object in an Element or Collection’ on page 10
for more information on object
collections. See
‘Object References’ on page 11
for information on object collection names
versus object names in a singular form.
VBS
appRef.Documents.Add(4000, 5000, 72, "myDocument", 5)
Note:
The enumerated value
5
at the end of the script statement indicates the value
psNewBitmap
for
the constant
PsNewDocumentMode
. The
Adobe Photoshop CS2 Visual Basic Scripting Reference
contains detailed information about enumerated values and constants.
JS
app.documents.add(4000, 5000, 72, "myDocument", DocumentMode.BITMAP)
Using Variables
A variable is a container for data you use in your script. For example, in the following AppleScript
statements the variables
docWidth
and
docHeight
replace the width and height specifications for the
new document.
●
Without variables:
make new document with properties {width:4 as inches, height:2 as inches}
●
With variables:
set docWidth to 4 inches
set docHeight to 2 inches
make new document with properties {docWidth, docHeight}