Adobe PHOTOSHOP CS 2.0 - SCRIPTING GUIDE Manual page 27

Table of Contents

Advertisement

Adobe Photoshop CS2 Scripting Guide
Note:
-- Sample script to create a new text item and
-- change its contents.
--target Photoshop CS2
tell application "Adobe Photoshop CS2"
-- Create a new document and art layer.
-- Change the art layer to be a text layer.
-- Get a reference to the text object and set its contents.
end tell
2. Click Run to run the script. Photoshop CS2 creates a new document, adds a new layer, changes the
layer's type to text and sets the text to "Hello, World"
Note:
Creating and Running a VBScript
Follow these steps to create and run a VBScript that displays the text Hello World! in a Photoshop CS2
document.
To create and run your first Photoshop CS2 VBScript:
1. Type the following script into a script or text editor.
Note:
Entering comments is optional.
Dim appRef
Set appRef = CreateObject( "Photoshop.Application" )
' Remember current unit settings and then set units to
' the value expected by this script
Dim originalRulerUnits
originalRulerUnits = appRef.Preferences.RulerUnits
appRef.Preferences.RulerUnits = 2
' Create a new 4x4 inch document and assign it to a variable.
Dim docRef
Dim artLayerRef
Dim textItemRef
Set docRef = appRef.Documents.Add(4, 4)
' Create a new art layer containing text
Set artLayerRef = docRef.ArtLayers.Add
artLayerRef.Kind = 2
' Set the contents of the text layer.
Set textItemRef = artLayerRef.TextItem
textItemRef.Contents = "Hello, World!"
' Restore unit setting
appRef.Preferences.RulerUnits = originalRulerUnits
The lines preceded by "--" are comments. Entering the comments is optional.
set docRef to make new document with properties ¬
{width:3 as inches, height:2 as inches}
set artLayerRef to make new art layer in docRef
set kind of artLayerRef to text layer
set contents of text object of artLayerRef to "Hello, World"
If you encounter errors, see
Photoshop CS2
'AppleScript Debugging' on page 32
Scripting basics
23

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs2

Table of Contents