Adobe Smoke Alarm CS3 Manuale Utente

Pagina di 85
Photoshop CS3
Adobe Photoshop CS3  Scripting Guide
 Photoshop CS3 Scripting Basics     16
Note:
The lines preceded by “--” are comments. Entering the comments is optional. 
-- Sample script to create a new text item and
-- change its contents.
--target Photoshop CS3
tell application "Adobe Photoshop CS3"
-- Create a new document and art layer.
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
-- Change the art layer to be a text layer.
set kind of artLayerRef to text layer
-- Get a reference to the text object and set its contents.
set contents of text object of artLayerRef to "Hello, World"
end tell
2. Click Run to run the script. Photoshop CS3 creates a new document, adds a new layer, changes the 
layer’s type to text and sets the text to “Hello, World”
Note:
If you encounter errors, refer to Introduction to Scripting, which has a section on AppleScript 
debugging. 
Creating and Running a VBScript 
Follow these steps to create and run a VBScript that displays the text Hello World! in a Photoshop CS3 
document. 
To create and run your first Photoshop CS3 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 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