Adobe PHOTOSHOP CS 2.0 - SCRIPTING GUIDE Manual page 79

Table of Contents

Advertisement

Adobe Photoshop CS2 Scripting Guide
appRef.DisplayDialogs = 3 'for PsDialogModes --> 3 (psDisplayNoDialogs)
docWidthInInches = 4
'see if any documents are open
'if none, create one using document defaults
If appRef.Documents.Count = 0 Then
helloWorldStr
'restore beginning preferences
appRef.Preferences.RulerUnits = startRulerUnits
appRef.Preferences.TypeUnits = startTypeUnits
appRef.DisplayDialogs = startDisplayDialogs
End Sub
2. Choose Run > Run Sub/UserForm or press F5 to run the script.
3. In Photoshop CS2, choose Edit > Preferences > Units & Rulers to verify that your preferences have
been returned to your original settings.
4. After viewing the document in Photoshop CS2, close the document without saving it.
5. To prepare the script for the next section, comment the statements that restore the beginning
preferences by adding straight single quotes as follows:
'app.Preferences.RulerUnits = startRulerUnits
'app.Preferences.TypeUnits = startTypeUnits
6. Name the script
JS
To work with document preferences:
1. Create the following script.
Note:
//create and assign variables for default preferences
startRulerUnits = app.preferences.rulerUnits
startTypeUnits = app.preferences.typeUnits
startDisplayDialogs = app.displayDialogs
//change settings
app.preferences.rulerUnits = Units.INCHES
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
//create and assign variables for document settings
docWidthInInches = 4
docHeightInInches = 2
resolution = 72
//use the length property of the documents object to
//find out if any documents are open
//if none are found, add a document
docHeightInInches = 2
resolution = 72
helloWorldStr = "Hello, World!"
app.Documents.Add docWidthInInches, docHeightInInches, resolution,
End If
HelloWorldDoc
See
'Creating and Running a JavaScript' on page 24
Photoshop CS2
and save it.
Scripting Photoshop CS2
for details on creating a JavaScript.
75

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs2

Table of Contents