Scripting Guide
Page 6
... for each of these languages through the object browsers available for scripting the Photoshop application. Chapter 4 covers the Action Manager, which allows you to scripting Adobe® Photoshop® CS4 on page 22. Code examples are used in three languages: ➤ AppleScript... ➤ VBScript ➤ JavaScriptTM NOTE: Separate Photoshop scripting reference information is provided for each language. Chapter...
... for each of these languages through the object browsers available for scripting the Photoshop application. Chapter 4 covers the Action Manager, which allows you to scripting Adobe® Photoshop® CS4 on page 22. Code examples are used in three languages: ➤ AppleScript... ➤ VBScript ➤ JavaScriptTM NOTE: Separate Photoshop scripting reference information is provided for each language. Chapter...
Scripting Guide
Page 8
...could write a script that might be complex and affect many objects in the three reference manuals provided with Photoshop, see "Photoshop Object Model" on page 11. ➤ For information on selecting a scripting language, refer to the ...on page 21. See "Viewing Photoshop Objects, Commands, and Methods" on 8 Scripting allows you to extend those benefits by a collection of this installation: Adobe Photoshop CS4 AppleScript Scripting Reference, Adobe Photoshop CS4 Visual Basic Scripting Reference, and Adobe Photoshop CS4 JavaScript Scripting Reference. Scripting Overview ...
...could write a script that might be complex and affect many objects in the three reference manuals provided with Photoshop, see "Photoshop Object Model" on page 11. ➤ For information on selecting a scripting language, refer to the ...on page 21. See "Viewing Photoshop Objects, Commands, and Methods" on 8 Scripting allows you to extend those benefits by a collection of this installation: Adobe Photoshop CS4 AppleScript Scripting Reference, Adobe Photoshop CS4 Visual Basic Scripting Reference, and Adobe Photoshop CS4 JavaScript Scripting Reference. Scripting Overview ...
Scripting Guide
Page 10
... main startup folder, it finds in the startup folders. ➤ On Windows, the startup folder for user-defined scripts is: C:\Program Files\Common Files\Adobe\Startup Scripts CS4\Adobe Photoshop ➤ On Mac OS, the startup folder for execution. For more information, please refer to Introduction to select scripts installed in the Scripts folder...
... main startup folder, it finds in the startup folders. ➤ On Windows, the startup folder for user-defined scripts is: C:\Program Files\Common Files\Adobe\Startup Scripts CS4\Adobe Photoshop ➤ On Mac OS, the startup folder for execution. For more information, please refer to Introduction to select scripts installed in the Scripts folder...
Scripting Guide
Page 16
... used as classes, and these classes are constants. CHAPTER 2: Photoshop Scripting Basics Photoshop Object Model 16 Additional objects The Photoshop object model includes additional objects beyond the ones described in the Adobe Photoshop CS4 Visual Basic Scripting Reference. For example: ➤ The color ... different than the constant values for the property. For example, look up the art ArtLayer object in either the Adobe Photoshop CS4 JavaScript Scripting Reference or in the containment hierarchy above. For example, with different constant values. e.g., the BMP save...
... used as classes, and these classes are constants. CHAPTER 2: Photoshop Scripting Basics Photoshop Object Model 16 Additional objects The Photoshop object model includes additional objects beyond the ones described in the Adobe Photoshop CS4 Visual Basic Scripting Reference. For example: ➤ The color ... different than the constant values for the property. For example, look up the art ArtLayer object in either the Adobe Photoshop CS4 JavaScript Scripting Reference or in the containment hierarchy above. For example, with different constant values. e.g., the BMP save...
Scripting Guide
Page 18
...contents. --target Photoshop CS4 tell application "Adobe Photoshop CS4" -- Photoshop 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 create a new text item and -- CHAPTER 2: Photoshop Scripting Basics ... set kind of artLayerRef to make new art layer in docRef -- change its contents. Change the art layer to run your first Photoshop AppleScript: 1. NOTE: The default location for the Script Editor is optional. -- set docRef to "Hello, World" end tell 2....
...contents. --target Photoshop CS4 tell application "Adobe Photoshop CS4" -- Photoshop 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 create a new text item and -- CHAPTER 2: Photoshop Scripting Basics ... set kind of artLayerRef to make new art layer in docRef -- change its contents. Change the art layer to run your first Photoshop AppleScript: 1. NOTE: The default location for the Script Editor is optional. -- set docRef to "Hello, World" end tell 2....
Scripting Guide
Page 20
...supports JavaScript files that use a .js extension. 3. Do either of the text layer. CHAPTER 2: Photoshop Scripting Basics Creating a sample Hello World script 20 To create and run your Adobe Photoshop CS4 directory. The scripts do not appear on the File > Scripts menu until you restart the application. ...Save file as a text file with a .jsx file name extension in the Presets/Scripts folder in your first Photoshop JavaScript: 1. NOTE: Entering ...
...supports JavaScript files that use a .js extension. 3. Do either of the text layer. CHAPTER 2: Photoshop Scripting Basics Creating a sample Hello World script 20 To create and run your Adobe Photoshop CS4 directory. The scripts do not appear on the File > Scripts menu until you restart the application. ...Save file as a text file with a .jsx file name extension in the Presets/Scripts folder in your first Photoshop JavaScript: 1. NOTE: Entering ...
Scripting Guide
Page 21
... script. Script Editor displays an Open Dictionary dialog. 2. In Script Editor, choose File > Open Dictionary. TIP: Throughout this installation: ➤ Adobe Photoshop CS4 AppleScript Scripting Reference ➤ Adobe Photoshop CS4 Visual Basic Scripting Reference ➤ Adobe Photoshop CS4 JavaScript Scripting Reference In addition, you can use to create AppleScripts, VBScript scripts, and JavaScripts for more information. You will help...
... script. Script Editor displays an Open Dictionary dialog. 2. In Script Editor, choose File > Open Dictionary. TIP: Throughout this installation: ➤ Adobe Photoshop CS4 AppleScript Scripting Reference ➤ Adobe Photoshop CS4 Visual Basic Scripting Reference ➤ Adobe Photoshop CS4 JavaScript Scripting Reference In addition, you can use to create AppleScripts, VBScript scripts, and JavaScripts for more information. You will help...
Scripting Guide
Page 22
... should do not need to the Photoshop objects icon. 9. In the Browse drop-down menu. 5. You can select one to display the objects and commands available for VBScript in Microsoft Word to display more information abut the class. On the COM tab, find "Adobe Photoshop CS4 Object Library". Choose View > Object... Browser. 4. Viewing Photoshop's type library (VBS) You can also use the VBA editor in...
... should do not need to the Photoshop objects icon. 9. In the Browse drop-down menu. 5. You can select one to display the objects and commands available for VBScript in Microsoft Word to display more information abut the class. On the COM tab, find "Adobe Photoshop CS4 Object Library". Choose View > Object... Browser. 4. Viewing Photoshop's type library (VBS) You can also use the VBA editor in...
Scripting Guide
Page 23
...hierarchy or leave it out, whichever makes your script in the following to target the application: Dim appRef Set appRef = CreateObject("Photoshop.Application") JS In JavaScript, because you include all commands in the tell block, there is not possible to add a new ... VBS In VBScript, do the following statements: tell application "Adobe Photoshop CS4" ... end tell NOTE: Because you do not reference the Application object. CHAPTER 3: Scripting Photoshop Creating New Objects in a Script 23 AS To target Photoshop in AppleScript, you use the object's collection name to name...
...hierarchy or leave it out, whichever makes your script in the following to target the application: Dim appRef Set appRef = CreateObject("Photoshop.Application") JS In JavaScript, because you include all commands in the tell block, there is not possible to add a new ... VBS In VBScript, do the following statements: tell application "Adobe Photoshop CS4" ... end tell NOTE: Because you do not reference the Application object. CHAPTER 3: Scripting Photoshop Creating New Objects in a Script 23 AS To target Photoshop in AppleScript, you use the object's collection name to name...
Scripting Guide
Page 24
...and Document objects that contains the object. make and set command to create a variable to hold a reference to , an object in the Adobe Photoshop CS4 AppleScript Scripting Reference. In the following example, the variable named docRef holds a reference to the new document: set statement. make or set ...Document object that will be used with an object, look up the make new document You can use the set commands in the Adobe Photoshop CS4 AppleScript Scripting Reference or in the following sample, which is a plural form of the object description. The following sample creates an ...
...and Document objects that contains the object. make and set command to create a variable to hold a reference to , an object in the Adobe Photoshop CS4 AppleScript Scripting Reference. In the following example, the variable named docRef holds a reference to the new document: set statement. make or set ...Document object that will be used with an object, look up the make new document You can use the set commands in the Adobe Photoshop CS4 AppleScript Scripting Reference or in the following sample, which is a plural form of the object description. The following sample creates an ...
Scripting Guide
Page 25
... methods in the script. For more information, look up the Layers object in the Adobe Photoshop CS4 Visual Basic Scripting Reference. For more information, look up the Layers object in the Adobe Photoshop CS4 JavaScript Scripting Reference. Similar to VBScript, the JavaScript statement to create a document is:... following statement is no Add() method for the Documents object. CHAPTER 3: Scripting Photoshop Setting the Active Object 25 If you look up in the Document object in the Adobe Photoshop CS4 Visual Basic Scripting Reference or in a layer, you must first bring the layer...
... methods in the script. For more information, look up the Layers object in the Adobe Photoshop CS4 Visual Basic Scripting Reference. For more information, look up the Layers object in the Adobe Photoshop CS4 JavaScript Scripting Reference. Similar to VBScript, the JavaScript statement to create a document is:... following statement is no Add() method for the Documents object. CHAPTER 3: Scripting Photoshop Setting the Active Object 25 If you look up in the Document object in the Adobe Photoshop CS4 Visual Basic Scripting Reference or in a layer, you must first bring the layer...
Scripting Guide
Page 26
... current document to docRef --here you find activeLayer and activeHistoryState as properties. if you look at application in the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the ExtendScript Object Model Viewer, you would include command statements 'that perform actions on... document Set app.ActiveDocument = otherDocRef Similarly, if you look at the Application object in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Photoshop AppleScript Dictionary, you could --make a different document the active document --use the ActiveDocument property of...
... current document to docRef --here you find activeLayer and activeHistoryState as properties. if you look at application in the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the ExtendScript Object Model Viewer, you would include command statements 'that perform actions on... document Set app.ActiveDocument = otherDocRef Similarly, if you look at the Application object in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Photoshop AppleScript Dictionary, you could --make a different document the active document --use the ActiveDocument property of...
Scripting Guide
Page 27
...appRef.ActiveDocument = docRef docRef.ActiveLayer = docRef.Layers(1) Look up the activeLayer property on the Document object in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Visual Basic Object Browser. NOTE: You can also use the name of the ... have been previously defined and assigned ' to the application object and a document object that perform actions on the Document object in the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the ExtendScript Object Model Viewer. See "Referencing ArtLayer objects" on page 38. See "Referencing ArtLayer objects...
...appRef.ActiveDocument = docRef docRef.ActiveLayer = docRef.Layers(1) Look up the activeLayer property on the Document object in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Visual Basic Object Browser. NOTE: You can also use the name of the ... have been previously defined and assigned ' to the application object and a document object that perform actions on the Document object in the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the ExtendScript Object Model Viewer. See "Referencing ArtLayer objects" on page 38. See "Referencing ArtLayer objects...
Scripting Guide
Page 29
... will be used to the open() command. For example: ➤ In the Adobe Photoshop CS4 AppleScript Scripting Reference look up the Photo CD open options class or the EPS open objects class. ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or the Adobe Photoshop CS4 JavaScript Scripting Reference, look up the properties for each of images in...
... will be used to the open() command. For example: ➤ In the Adobe Photoshop CS4 AppleScript Scripting Reference look up the Photo CD open options class or the EPS open objects class. ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or the Adobe Photoshop CS4 JavaScript Scripting Reference, look up the properties for each of images in...
Scripting Guide
Page 30
....Preferences.RulerUnits = originalRulerUnits NOTE: The ExtendScript File object expects Universal Resource Identifier (URI) notation. tell application "Adobe Photoshop CS4" set to the height and width properties if the original shape is not twice as wide as it is tall. CHAPTER 3: Scripting...class:PDF open options, ¬ mode:RGB, resolution:72, use antialias:true, page:3} end timeout end tell Dim appRef Set appRef = CreateObject("Photoshop.Application") 'Remember unit settings and set myFilePath to alias "OS X 10.4.8 US:Users:psauto:Desktop:opal_screen.pdf" with timeout of 1 = psPixels...
....Preferences.RulerUnits = originalRulerUnits NOTE: The ExtendScript File object expects Universal Resource Identifier (URI) notation. tell application "Adobe Photoshop CS4" set to the height and width properties if the original shape is not twice as wide as it is tall. CHAPTER 3: Scripting...class:PDF open options, ¬ mode:RGB, resolution:72, use antialias:true, page:3} end timeout end tell Dim appRef Set appRef = CreateObject("Photoshop.Application") 'Remember unit settings and set myFilePath to alias "OS X 10.4.8 US:Users:psauto:Desktop:opal_screen.pdf" with timeout of 1 = psPixels...
Scripting Guide
Page 31
...false, ¬ format options:standard, matte:background color matte} save current document in file myFile as a .jpeg file. AS tell application "Adobe Photoshop CS4" make new document set myFile to "OS X 10.4.8 US:Users:psauto:Desktop:Rat.jpg" set myOptions to open" on page 29 for..., look up the class EPS save options. ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference or in Photoshop are illustrated below. To find out about properties for saving documents in the Adobe Photoshop CS4 JavaScript Scripting Reference look up the object that the Open and Save ...
...false, ¬ format options:standard, matte:background color matte} save current document in file myFile as a .jpeg file. AS tell application "Adobe Photoshop CS4" make new document set myFile to "OS X 10.4.8 US:Users:psauto:Desktop:Rat.jpg" set myOptions to open" on page 29 for..., look up the class EPS save options. ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference or in Photoshop are illustrated below. To find out about properties for saving documents in the Adobe Photoshop CS4 JavaScript Scripting Reference look up the object that the Open and Save ...
Scripting Guide
Page 32
...units of settings to inch units set type units of settings to pixel units In the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the Photoshop AppleScript Dictionary, look up class settings-object to view all of the settings properties you must... = 1 'for psNoMatte jpgSaveOptions.Quality = 1 appRef.ActiveDocument.SaveAs "c:\temp\myFile2", _ jpgSaveOptions, True, 2 'for PsTypeUnits --> 1 (psPixels) In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Visual Basic Object Browser, look up the Preferences object to view all of the settings properties you display...
...units of settings to inch units set type units of settings to pixel units In the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the Photoshop AppleScript Dictionary, look up class settings-object to view all of the settings properties you must... = 1 'for psNoMatte jpgSaveOptions.Quality = 1 appRef.ActiveDocument.SaveAs "c:\temp\myFile2", _ jpgSaveOptions, True, 2 'for PsTypeUnits --> 1 (psPixels) In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Visual Basic Object Browser, look up the Preferences object to view all of the settings properties you display...
Scripting Guide
Page 33
... Allowing or Preventing Dialogs It is important to be sitting at the machine. displayDialogs = DialogModes.NO In the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer, look up the Application object property DisplayDialogs. preferences....rulerUnits = Units.INCHES preferences.typeUnits = TypeUnits.PIXELS In the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer, look up the Application object property displayDialogs, and...
... Allowing or Preventing Dialogs It is important to be sitting at the machine. displayDialogs = DialogModes.NO In the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer, look up the Application object property DisplayDialogs. preferences....rulerUnits = Units.INCHES preferences.typeUnits = TypeUnits.PIXELS In the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer, look up the Application object property displayDialogs, and...
Scripting Guide
Page 35
...units of settings set ruler units of settings to inch units set duckFile to alias ¬ "OS X 10.4.8 US:Applications:Adobe Photoshop CS4:Samples:Ducky.tif" open duckFile set docRef to current document resize image docRef width 4 height 4 resize canvas docRef width 4 ... (psInches) Set docRef = appRef.Open(appRef.Path & "\Samples\Ducky.tif") docRef.ResizeImage 4,4 docRef.ResizeCanvas 4,4 'Trim the document with the Photoshop Object Model 35 Manipulating a document object The following examples demonstrate how to do the following: ➤ Save the existing ruler unit preferences, and...
...units of settings set ruler units of settings to inch units set duckFile to alias ¬ "OS X 10.4.8 US:Applications:Adobe Photoshop CS4:Samples:Ducky.tif" open duckFile set docRef to current document resize image docRef width 4 height 4 resize canvas docRef width 4 ... (psInches) Set docRef = appRef.Open(appRef.Path & "\Samples\Ducky.tif") docRef.ResizeImage 4,4 docRef.ResizeCanvas 4,4 'Trim the document with the Photoshop Object Model 35 Manipulating a document object The following examples demonstrate how to do the following: ➤ Save the existing ruler unit preferences, and...
Scripting Guide
Page 37
... document with contents ¬ {class:RGB color, red:255, green:0, blue:0} end tell Dim appRef Set appRef = CreateObject("Photoshop.Application") ' Create a new art layer at the beginning of the current document. tell application "Adobe Photoshop CS4" make new document make new art layer at beginning of current document ¬ with properties {name:"MyBlendLayer", blend...
... document with contents ¬ {class:RGB color, red:255, green:0, blue:0} end tell Dim appRef Set appRef = CreateObject("Photoshop.Application") ' Create a new art layer at the beginning of the current document. tell application "Adobe Photoshop CS4" make new document make new art layer at beginning of current document ¬ with properties {name:"MyBlendLayer", blend...