Adobe 65048332 Manual page 63

Scripting guide
Table of Contents

Advertisement

C
3: Scripting Photoshop
HAPTER
'restore beginning preferences
appRef.Preferences.RulerUnits = startRulerUnits
appRef.Preferences.TypeUnits = startTypeUnits
appRef.DisplayDialogs = startDisplayDialogs
Double click the file name in Windows Explorer to run the script.
2. In Photoshop, choose Edit > Preferences > Units & Rulers to verify that your preferences have been
returned to your original settings.
3. After viewing the document in Photoshop, close the document without saving it.
4. Name the script
JS
To work with document preferences:
1. Create the following script.
N
OTE
//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
docName = "Hello World"
//use the length property of the documents object to
//find out if any documents are open
//if none are found, add a document
if (app.documents.length == 0)
app.documents.add(docWidthInInches, docHeightInInches, resolution, docName)
//restore beginning preferences
app.preferences.rulerunits = startRulerUnits
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
2. Name the script
3. Open Photoshop and choose File > Scripts > HelloWorldDoc to run the script.
4. Choose Edit > Preferences > Units & Rulers to verify that your preferences have been returned to
your original settings.
5. After viewing the document in Photoshop, close the document without saving it.
6. Save the script.
HelloWorldDoc
: See
"Creating and running a JavaScript" on page 19
HelloWorldDoc.jsx
and save it.
and save it in the Presets/Scripts folder.
Advanced Scripting 63
for details on creating a JavaScript.

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

65048599Photoshop cs5

Table of Contents