Adobe 23101764 - Photoshop CS - PC Manual page 19

Scripting guide
Hide thumbs Also See for 23101764 - Photoshop CS - PC:
Table of Contents

Advertisement

AppleScript Sample Code
This code contains AppleScript commands that instruct the Photoshop application to create a
new document with width and height in inches and place an art layer within the document.
The art layer is then changed to a text layer, whose contents are set to "Hello World!".
tell application "Adobe Photoshop CS"
end tell
Visual Basic Sample Code
This code contains Visual Basic commands that instruct Photoshop to configure the width and
height of a new document in inches and place an art layer within the document. The art layer is
then changed to a text item, whose contents are set to "Hello World!". Initial unit settings are
restored after the script is run.
Dim appRef As New Photoshop.Application
Dim originalRulerUnits As Photoshop.PsUnits
originalRulerUnits = appRef.Preferences.RulerUnits
appRef.Preferences.RulerUnits = psInches
Dim docRef As Photoshop.Document
Dim artLayerRef As Photoshop.ArtLayer
Dim textItemRef As Photoshop.TextItem
Set docRef = appRef.Documents.Add(4, 2, 72, "Hello, World!")
Set artLayerRef = docRef.ArtLayers.Add
artLayerRef.Kind = psTextLayer
Set textItemRef = artLayerRef.TextItem
textItemRef.Contents = "Hello, World!"
appRef.Preferences.RulerUnits = originalRulerUnits
Photoshop CS Scripting Guide
set docRef to make new document with properties ¬
{width:4 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!"
Scripting basics
2
Object Model
15

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs

Table of Contents