Adobe PHOTOSHOP CS 2.0 - SCRIPTING GUIDE Manual page 28

Table of Contents

Advertisement

Adobe Photoshop CS2 Scripting Guide
2. Save file as a text file with a
3. Double-click the file in Windows Explorer to run the script.
The script opens Photoshop CS2.
Creating and Running a JavaScript
Follow these steps to create and run a JavaScript that displays the text Hello World! in a Photoshop CS2
document.
Because you will be actually using Photoshop CS2 to run your JavaScripts, it is not necessary to include
code that opens Photoshop CS2 at the beginning of the script.
Note:
Adobe has created the Extend Script scripting language to augment JavaScript for use with
Photoshop CS2. You can use the Extend Script command
application and create the ability to open JavaScripts that manipulate Photoshop CS2 from
anywhere in your file system. See the "Script UI" chapter of the Adobe Photoshop CS2 JavaScript
Scripting Reference for more information.
To create and run your first Photoshop CS2 JavaScript:
1. Type the following script.
Note:
// Hello Word Script
// Remember current unit settings and then set units to
// the value expected by this script
var originalUnit = preferences.rulerUnits
preferences.rulerUnits = Units.INCHES
// Create a new 4x4 inch document and assign it to a variable
var docRef = app.documents.add( 4, 4 )
// Create a new art layer containing text
var artLayerRef = docRef.artLayers.add()
artLayerRef.kind = LayerKind.TEXT
// Set the contents of the text layer.
var textItemRef = artLayerRef.textItem
textItemRef.contents = "Hello, World"
// Release references
docRef = null
artLayerRef = null
textItemRef = null
// Restore original ruler unit setting
app.preferences.rulerUnits = originalUnit
2. Save file as a text file with a
Photoshop CS2 directory.
Note:
Note:
.vbs
Entering comments is optional.
.jsx
You must place your JavaScripts in the Presets > Scripts folder in order to make the scripts
accessible from the File > Scripts menu in Photoshop CS2. The scripts do not appear on the File
> Scripts menu until you restart the application.
Photoshop CS2 also supports JavaScript files that use a
Photoshop CS2
file name extension.
file name extension in the Presets > Scripts folder in your Adobe
to target the Photoshop CS2
#target
extension.
.js
Scripting basics
24

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs2

Table of Contents