Creating And Running A Vbscript; Creating And Running A Javascript - Adobe 65014912 Manual

Photoshop cs4 extended
Table of Contents

Advertisement

C
2: Photoshop Scripting Basics
HAPTER

Creating and running a VBScript

Follow these steps to create and run a VBScript that displays the text Hello World! in a Photoshop
document.
To create and run your first Photoshop VBScript:
1. Type the following script into a script or text editor.
N
OTE
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 2x4 inch document and assign it to a variable.
Dim docRef
Dim artLayerRef
Dim textItemRef
Set docRef = appRef.Documents.Add(2, 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
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.

Creating and running a JavaScript

Follow these steps to create and run a JavaScript that displays the text Hello World! in a Photoshop
document.
Because you will be actually using Photoshop to run your JavaScripts, it is not necessary to include code
that opens Photoshop at the beginning of the script.
N
: Adobe has created the Extend Script scripting language to augment JavaScript for use with
OTE
Photoshop. You can use the Extend Script command
create the ability to open JavaScripts that manipulate Photoshop from anywhere in your file system. See
the "Script UI" chapter of the JavaScript Tools Guide for more information.
: Entering comments is optional.
.vbs
file name extension.
#target
Creating a sample Hello World script 19
to target the Photoshop application and

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents