Table of Contents

Advertisement

ADOBE PHOTOSHOP CS4
SCRIPTING GUIDE

Advertisement

Table of Contents
loading

Summary of Contents for Adobe 65014912

  • Page 1 ADOBE PHOTOSHOP CS4 SCRIPTING GUIDE...
  • Page 2 The information in this document is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by Adobe Systems Inc. Adobe Systems Inc. assumes no responsibility or liability for any errors or inaccuracies that may appear in this document. The software described in this document is furnished under license and may only be used or copied in accordance with the terms of such license.
  • Page 3: Table Of Contents

    Contents Introduction ............. . 6 About this Manual .
  • Page 4 Contents Setting the active layer ............. . 27 Setting the active channels .
  • Page 5 Contents Unit value usage ..............57 Setting ruler and type units in a script .
  • Page 6: Introduction

    Introduction About this Manual This manual provides an introduction to scripting Adobe® Photoshop® CS4 on Mac OS® and Windows®. Chapter 1 covers the basic conventions used in this manual. Chapter 2 covers a brief overview of scripting, how to execute scripts, and the Photoshop object model.
  • Page 7 1: Introduction HAPTER In this case, display dialogs property and displayDialogs For larger blocks of code, scripting examples are listed on separate lines. layer 1 of layer set 1 of current document appRef.ActiveDocument.LayerSets(1).Layers(1) app.activeDocument.layerSets[0].layers[0] Finally, tables are sometimes used to organize lists of values specific to each scripting language. refers to the AppleScript property, refers to the JavaScript property.
  • Page 8: Photoshop Scripting Basics

    ➤ For detailed information on Photoshop objects and commands, please use the reference information in the three reference manuals provided with this installation: Adobe Photoshop CS4 AppleScript Scripting Reference, Adobe Photoshop CS4 Visual Basic Scripting Reference, and Adobe Photoshop CS4 JavaScript Scripting Reference.
  • Page 9: Scripting Support In Photoshop

    ” ➤ A single script can perform actions that involve multiple applications. For example, depending on the scripting language you are using, you could target both Photoshop and another Adobe Creative Suite 4 Application, such as Adobe Illustrator ➤...
  • Page 10: Executing Other Scripts

    ~/Library/Application Support/Adobe/Startup Scripts CS4/Adobe Photoshop If your script is in this main startup folder, it is also executed by all other Adobe Creative Suite 3 applications at startup. If such a script is meant to be executed only by Photoshop, it must include code such as the following: if( BridgeTalk.appName == "photoshop"...
  • Page 11: Photoshop Object Model

    A document object model (DOM) is an application programming interface (API), which allows you to programmatically access various components of a document (as defined for that application) through a scripting language. For additional information about Adobe object models and the scripting languages that support them, see Introduction to Scripting.
  • Page 12: Application And Document Classes

    2: Photoshop Scripting Basics HAPTER Photoshop containment hierarchy (showing key classes only) Channel Selection Path Item Sub Path Item Path Point Application and document classes Application appropriate application in order to run correctly. See on page class is used to make modifications to the document image. By using the Document you can crop, rotate or flip the canvas, resize the image or canvas, and trim the image.
  • Page 13: Layer Comp Class

    2: Photoshop Scripting Basics HAPTER is a class that comprises multiple layers. Think of it as a folder on your desktop. Since folders Layer Set can contain other folders, a layer set is recursive. That is, one layer set may call another layer set in the Object Model hierarchy.
  • Page 14: Path Item, Sub Path Item, And Path Point Classes

    2: Photoshop Scripting Basics HAPTER Path Item, Sub Path Item, and Path Point classes class represents information about a drawing object, such as the outline of a shape, or a Path Item curved line. The Sub Path Item of the shape. The PathItem object”...
  • Page 15 2: Photoshop Scripting Basics HAPTER Object name Description Path Item A drawing object, such as the outline of a shape or a straight or curved line Channel Pixel information about an image’s color. Art Layer A layer class within a document that allows you to work on one element of an image without affecting other elements in the image.
  • Page 16: Additional Objects

    For more information about using comments, see Introduction to Scripting. For example, look up the art Reference or in the Adobe Photoshop CS4 Visual Basic Scripting Reference. One of the properties of this object is Kind( kind allowed values for the property.
  • Page 17: Creating A Sample Hello World Script

    2: Photoshop Scripting Basics HAPTER Creating a sample Hello World script This section demonstrates a very simple script in each of the three scripting languages for Photoshop. Traditionally, the first thing to accomplish in any programming environment is the display of a "Hello World"...
  • Page 18: Creating And Running An Applescript

    -- Sample script to create a new text item and -- change its contents. --target Photoshop CS4 tell application "Adobe Photoshop CS4" -- 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.
  • Page 19: Creating And Running A Vbscript

    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. : Adobe has created the Extend Script scripting language to augment JavaScript for use with Photoshop. You can use the Extend Script command create the ability to open JavaScripts that manipulate Photoshop from anywhere in your file system.
  • Page 20 Scripts folder and choose your script. ➣ Start or restart Photoshop, and then choose File > Scripts, and then select your script from the Scripts menu. file name extension in the Presets/Scripts folder in your Adobe .jsx Creating a sample Hello World script 20 extension.
  • Page 21: Scripting Photoshop

    1. In Script Editor, choose File > Open Dictionary. Script Editor displays an Open Dictionary dialog. 2. Choose Adobe Photoshop CS4, and then click Open. Script Editor opens Photoshop and then displays the Photoshop dictionary, which lists objects as well as the commands, properties and elements associated with each object.
  • Page 22: Viewing Photoshop's Type Library (Vbs)

    To view the VBS object library in Microsoft Word: 1. Start Word, and then choose Tools > Macro > Visual Basic Editor. 2. Choose Tools > References, and then select the Adobe Photoshop Type Library check box and click 3. Choose View > Object Browser.
  • Page 23: Creating New Objects In A Script

    3: Scripting Photoshop HAPTER To target Photoshop in AppleScript, you must enclosing your script in the following statements: tell application "Adobe Photoshop CS4" end tell : Because you include all commands in the object throughout the script. Application In VBScript, do the following to target the application: Dim appRef Set appRef = CreateObject("Photoshop.Application")
  • Page 24 Photoshop AppleScript Dictionary. See ➤ To find out which commands can be used with an object, look up the object in the Adobe Photoshop CS4 AppleScript Scripting Reference. If an object has valid commands, there will be a “Valid Commands”...
  • Page 25: Setting The Active Object

    In VBScript, you use the ActiveLayer ➤ In JavaScript, you use the activeLayer object in the Adobe Photoshop CS4 Visual Basic Scripting Reference or in the Document object. Similarly, the Documents object does. object is an exception because, although it is a collection object, it does not include an...
  • Page 26: Setting The Active Document

    'bring otherDocRef front-most as the new active document Set app.ActiveDocument = otherDocRef object in the Adobe Photoshop CS4 JavaScript Scripting Application object, you will find activeLayer in the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the application Setting the Active Object 26 activeDocument as properties. activeHistoryState , and so on.
  • Page 27: Setting The Active Layer

    (ActiveLayer/activeLayer) object to set the active layer. In order to set the active layer for a document, the property on the object in the Adobe Photoshop CS4 Visual Basic Document “Referencing ArtLayer objects” on page property on the...
  • Page 28: Setting The Active Channels

    3: Scripting Photoshop HAPTER Setting the active channels More than one channel can be active at a time, so the current ActiveChannels/activeChannels value. In order to set the active channels of a document, it must be the active document. Set the active channels to the first and third channel using a channel array: set current channels of current document to ¬...
  • Page 29: Specifying File Formats To Open

    In the Adobe Photoshop CS4 AppleScript Scripting Reference look up the EPS open objects ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or the Adobe Photoshop CS4 JavaScript Scripting Reference, look up the The following examples demonstrate how to open a generic (multi-page/multi-image) PDF document with the following specifications: ➤...
  • Page 30 The document’s original shape will change to conform to the height and width properties if the original shape is not twice as wide as it is tall. tell application "Adobe Photoshop CS4" set myFilePath to alias "OS X 10.4.8 US:Users:psauto:Desktop:opal_screen.pdf"...
  • Page 31: Saving A Document

    ➤ In the Adobe Photoshop CS4 AppleScript Scripting Reference, look up the class ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference or in the Adobe Photoshop CS4 JavaScript Scripting Reference look up Save Classes Photoshop...
  • Page 32: Setting Application Preferences

    VBScript script, you must indicate its containment in the appRef.Preferences.RulerUnits = 2 'for PsUnits --> 2 (psInches) appRef.Preferences.TypeUnits = 1 'for PsTypeUnits --> 1 (psPixels) In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Visual Basic Object Browser, look up Preferences property on the...
  • Page 33: Allowing Or Preventing Dialogs

    'for PsDialogModes --> 3 (psDisplayNoDialogs) Note that, because object in the script to get to the property. Application In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Visual Basic Object Browser, look up Application constant PsDialogModes To set dialog preferences, you use the displayDialogs = DialogModes.NO...
  • Page 34: Using The Application Object

    VBS: Set fontsInstalled = AppRef.Fonts ➣ var fontsInstalled = app.fonts ➤ The amount of unused memory available to Adobe Photoshop, using the (FreeMemory/freeMemory) ➤ The location of the Preferences folder, using the (PreferencesFolder/preferencesFolder) For further information, look up the properties of the object browser of the language you are using.
  • Page 35: Manipulating A Document Object

    ¬ "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 height 4 trim docRef basing trim on top left pixel with top trim ¬...
  • Page 36: Working With Layer Objects

    3: Scripting Photoshop HAPTER 'Crop the document with ' angle=45, width=20,height=20 docRef.Crop Array(100,200,400,500),45,20,20 docRef.FlipCanvas 1 ' psHorizontal 'restore ruler units appRef.Preferences.RulerUnits = startRulerUnits //save original ruler units, then assign it to inches startRulerUnits = app.preferences.rulerUnits app.preferences.rulerUnits = Units.INCHES //get a reference to the file, and open it var fileRef = new File(app.path + "/samples/ducky.tif") var docRef = app.open(fileRef) //this sample script assumes the ruler units have been set to inches...
  • Page 37: Creating An Artlayer Object

    HAPTER Creating an ArtLayer object The following examples demonstrate how to create an 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 mode:normal} select all current document fill selection of current document with contents ¬...
  • Page 38: Creating A Layer Set Object

    Creating a Layer Set object The following examples show how to create a object in the current document: tell application "Adobe Photoshop CS4" make new document with properties {name:"My Document"} make new art layer at beginning of current document make new layer set after layer 1 of current document...
  • Page 39: Working With Layer Set Objects

    3: Scripting Photoshop HAPTER You can use the following syntax to refer to the layers by the names given them by the Application: layer 1 of layer set 1 of current document : Unlike object references in JavaScript or VBScript, AppleScript object reference names do not remain constant.
  • Page 40: Linking Layer Objects

    Look up applyStyle() Scripting Reference, or in the ExtendScript Object Model Viewer. command in the Adobe Photoshop CS4 AppleScript Scripting Reference or in the object in the Adobe Photoshop CS4 Visual Basic Scripting ArtLayer object in the Adobe Photoshop CS4 JavaScript Scripting ArtLayer object.
  • Page 41: Using The Text Item Object

    TextItem Also, look up the following: ➤ Kind/kind CS4 Visual Basic Scripting Reference, Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Visual Basic Object Browser and the ExtendScript Object Model Viewer. ➤ kind Scripting Reference or in the Photoshop AppleScript Dictionary.
  • Page 42: Adding And Manipulating Text In A Text Item Object

    In the Adobe Photoshop CS4 AppleScript Scripting Reference or in the Photoshop AppleScript Dictionary, look up the text-object ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Visual Basic Object Browser look up the TextItem with a text layer, look up the...
  • Page 43: Creating And Defining A Selection

    In the Adobe Photoshop CS4 AppleScript Scripting Reference or in the Photoshop AppleScript Dictionary, look up the command selection-object ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Visual Basic Object Browser, look Selection object. Selection ➤...
  • Page 44: Stroking The Selection Border

    3: Scripting Photoshop HAPTER var docRef = app.documents.add(500, 500) var shapeRef = [ [0,0], [0,100], [100,100], [100,0] docRef.selection.select(shapeRef) Stroking the selection border The following examples use the the boundaries around the current selection and set the stroke color and width. : The transparency parameter cannot be used for background layers.
  • Page 45: Filling A Selection

    3: Scripting Photoshop HAPTER by five pixels. See section ruler units. expand selection of current document by pixels 5 contract selection of current document by pixels 5 feather selection of current document by pixels 5 Dim selRef Set selRef = appRef.ActiveDocument.Selection selRef.Expand 5 selRef.Contract 5 selRef.Feather 5...
  • Page 46: Working With Channel Objects

    3: Scripting Photoshop HAPTER examples use the selection in a channel named that channel. set myChannel to make new channel of current document with properties ¬ {name:"My Channel", kind::selected area channel} store selection of current document into channel ¬ "My Channel" of current document combination type extended Set chanRef = docRef.Channels.Add chanRef.Name = "My Channel"...
  • Page 47: Using The Document Info Object

    For information about other types of information (properties) you can associate with a document, look up the following: ➤ In the Adobe Photoshop CS4 AppleScript Scripting Reference or in the Photoshop AppleScript Dictionary, look up the properties for the class ➤...
  • Page 48: Using Notifier Objects

    Add/add notification for. Many event IDs are listed in an Appendix in the Adobe Photoshop CS4 JavaScript Scripting Reference, Adobe Photoshop CS4 Visual Basic Scripting Reference, and Adobe Photoshop CS4 AppleScript Scripting Reference. Some events also operate on several types of objects, and the command requires an additional argument for a class ID, which identifies the object.
  • Page 49: Using The Pathitem Object

    HAPTER : Notification generally does not take effect on events that occur inside of a script, because these events are embedded with in an tell application "Adobe Photoshop CS4" delete notifiers end try make new notifier with properties {event:"Opn ", ¬...
  • Page 50 3: Scripting Photoshop HAPTER Dim appRef, docRef Dim lineArray(1), lineArray2(1), lineSubPathArray(0), myPathItem Set appRef = CreateObject("Photoshop.Application") ' create a document to work with Set docRef = appRef.Documents.Add(5000, 7000, 72, "Simple Line") 'line #1--it’s a straight line so the coordinates for anchor, left, and 'right for each point have the same coordinates 'First create the array of PathPointInfo objects.
  • Page 51: Working With Color Objects

    3: Scripting Photoshop HAPTER // Next create a SubPathInfo object, which holds the line array // in its entireSubPath property. var lineSubPathArray = new Array() lineSubPathArray[0] = new SubPathInfo() lineSubPathArray[0].operation = ShapeOperation.SHAPEXOR lineSubPathArray[0].closed = false lineSubPathArray[0].entireSubPath = lineArray //create the path item, using add. This method takes the SubPathInfo object //and returns a PathItem object, which is added to the pathItems collection // for the document.
  • Page 52: Solid Color Classes

    The following script, which assumes an RGB color model, gets the foreground color and then uses the command of the convert get foreground color convert color foreground color to CMYK Look up the following in the Adobe Photoshop CS4 AppleScript Scripting Reference or in the Photoshop AppleScript Dictionary: ➤ In the “Objects” section, the ➤...
  • Page 53: Comparing Colors

    3: Scripting Photoshop HAPTER Look up the following in the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Visual Basic Object Browser: ➤ model cmyk This example uses the be converted. The way to access the cmyk equivalent of the rgb color.
  • Page 54: Other Filters

    : In the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the Photoshop AppleScript Dictionary, look up the appRef.docRef.ActiveLayer.ApplyGaussianBlur 5 : In the Adobe Photoshop CS4 Visual Basic Scripting Reference, on in the Visual Basic Object Browser look up the ApplyGaussianBlur with “Apply.”...
  • Page 55: Using The Copy Merged Command/Method

    ArtLayer Selection method for the ArtLayer Understanding Clipboard Interaction 55 “Setting Application Preferences” on command, passing in a Copy/copy objects in the Adobe Photoshop CS4 Visual objects in the Adobe Photoshop CS4 Selection...
  • Page 56: Working With Units

    3: Scripting Photoshop HAPTER Working with Units Photoshop provides two rulers for documents. Using properties on the Preferences/Preferences rulers are: ➤ A graphics ruler used for most graphical layout measurements or operations on a document where height, width, or position are specified. You set measurement unit types for the graphics ruler using the (RulerUnits/rulerUnits) ➤...
  • Page 57: Using Unit Values In Calculations

    3: Scripting Photoshop HAPTER The values returned for a Photoshop property that uses units is returned as a value of the current ruler type. Getting the height of the document created above: set docHeight to height of current document returns a value of 5.0, which represents 5 inches based on the current ruler settings. In AppleScript, you can optionally ask for a property value as a particular type.
  • Page 58 HAPTER To use this table, do one of the following: ➤ Look up the properties of the class in the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the Photoshop AppleScript Dictionary. ➤ Look up the property of the object in the Adobe Photoshop CS4 Visual Basic Scripting Reference, the Adobe Photoshop CS4 JavaScript Scripting Reference, the Visual Basic Object Browser, or the ExtendScript Object Model Viewer.
  • Page 59: Setting Ruler And Type Units In A Script

    3: Scripting Photoshop HAPTER AppleScript crop (bounds, height, width) resize canvas (height, width) resize image (height, width) contract (by) expand (by) feather (by) select border (width) translate (delta x, delta y) translate boundary (delta x, delta y) Setting ruler and type units in a script The unit type settings of the two Photoshop rulers control how numbers are interpreted when dealing with properties and parameters that support unit values.
  • Page 60: Sample Workflow Automation Javascripts

    3: Scripting Photoshop HAPTER Sample Workflow Automation JavaScripts The following sample workflow automation JavaScripts are provided with Photoshop and demonstrate various kinds of scripting usage. The scripts are located in the directory. See “Creating and running a JavaScript” on page 19 folder.
  • Page 61: Working With Document Preferences

    Document Finally, the script restores the original preferences. To work with document preferences: 1. Create and run the following script. See tell application "Adobe Photoshop CS4" --make Photoshop CS4 the active (front-most) application activate --create variables for the default settings...
  • Page 62 3: Scripting Photoshop HAPTER --check to see whether any documents are open --if none are found, create a document --use the default document settings as its properties if (count of documents) is 0 then make new document with properties ¬ {width:theDocWidthInInches, height:theDocHeightInInches,¬...
  • Page 63 3: Scripting Photoshop HAPTER 'restore beginning preferences appRef.Preferences.RulerUnits = startRulerUnits appRef.Preferences.TypeUnits = startTypeUnits appRef.DisplayDialogs = startDisplayDialogs Double click the file name in Windows Explorer to run the script. 2. In Photoshop, choose Edit > Preferences > Units & Rulers to verify that your preferences have been returned to your original settings.
  • Page 64: Applying Color To A Text Item

    3. After viewing the document in Photoshop, close the document without saving it. : Look up the following classes in the Adobe Photoshop CS4 AppleScript Scripting Reference or in the Photoshop AppleScript Dictionary to see if you understand how you used them in this script: ➤...
  • Page 65 3. After viewing the document in Photoshop, close the document without saving it. : Look up the following classes in the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Visual Basic Object Browser to see if you understand how you used them in this script: ➤...
  • Page 66: Applying A Wave Filter

    3. After viewing the document in Photoshop, close Photoshop without saving the document. : Look up the following classes in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer to see if you understand how you used them in this script: ➤...
  • Page 67: Defining The Area Of A Selection Object

    3: Scripting Photoshop HAPTER ➤ Apply a wave filter to the selection. : The wave is a truncated sine curve. Defining the area of a selection object To define the area of a selection object, we create an array of coordinates, or points specified in pixels within the document.
  • Page 68 4. Save the script in the Script Editor. : Look up the following classes in the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the Photoshop AppleScript Dictionary to see if you understand how you used them in this script: ➤...
  • Page 69 3. After viewing the document in Photoshop, close the document without saving it. 4. Save the script. : Look up the following classes in the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Visual Basic Object Browser to see if you understand how you used them in this script: ➤...
  • Page 70 3. After viewing the document in Photoshop, close Photoshop without saving the document. : Look up the following classes in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer to see if you understand how you used them in this script: ➤...
  • Page 71: Applying A Motionblur Filter

    : Look up the Scripting Reference, or in the Visual Basic Object Browser to see if you understand how you used it in this script: HelloWorldDoc class in the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the motion blur HelloWorldDoc class:...
  • Page 72 Scripting Reference, or in the ExtendScript Object Model Viewer to see if you understand how you used it in this script. HelloWorldDoc class ArtLayer applyMotionBlur() Advanced Scripting 72 just above the statements that restore method in the Adobe Photoshop CS4 JavaScript...
  • Page 73: Action Manager

    To install the ScriptListener: 1. Select the file 2. Paste the file copy to the following location: ..\Adobe Photoshop CS4\Plug-Ins\Automate 3. Open Photoshop. : If Photoshop is already open, close it and then start it again. This will allow Photoshop to load the plug-in.
  • Page 74: Action Manager Scripting Objects

    2. Verify that a copy of the file Scripting\Utilities 3. Delete the file ..\Adobe Photoshop CS\Plug-Ins\Automate 4. Delete the log files : In Windows, even though you remove the ScriptListener from the Automate folder, it may continue to record actions. To prevent the time you finish playing a Photoshop action.
  • Page 75: Using The Action Manager From Javascript

    4: Action Manager HAPTER 7. Check for the script log files: ➣ In Windows, the log files are in your desktop. ➣ On Mac OS, the log files are on the desktop. Using the Action Manager from JavaScript The section demonstrates how to use the contents of the script.
  • Page 76: Using The Action Manager From A Vbs Script

    4: Action Manager HAPTER 4. Wrap the code in a JavaScript function. In the following example, the function name is function emboss( angle, height, amount ) var id19 = charIDToTypeID( "Embs" ); var desc4 = new ActionDescriptor(); var id20 = charIDToTypeID( "Angl" ); desc4.putInteger( id20, angle );...
  • Page 77 4: Action Manager HAPTER To create a VBScript from the ScriptListener output: 1. Open ScriptingListenerVB.log At the end of the file you will see code similar to the following (although your numbers may be different): DIM objApp SET objApp = CreateObject("Photoshop.Application") REM Use dialog mode 3 for show no dialogs DIM dialogMode dialogMode = 3...
  • Page 78 4: Action Manager HAPTER 4. Wrap the code in a VBScript function. In the following example, the function name is creation of the Photoshop application object needs to be outside of the function, as we will explain in the next step. DIM objApp SET objApp = CreateObject("Photoshop.Application") Function Emboss( angle, height, amount )
  • Page 79: Running Javascript-Based Action Manager Code From Vbscript

    4: Action Manager HAPTER Function Emboss( angle, height, amount ) REM Use dialog mode 3 for show no dialogs DIM dialogMode dialogMode = 3 DIM id9 id9 = objApp.CharIDToTypeID( "Embs" ) DIM desc4 SET desc4 = CreateObject( "Photoshop.ActionDescriptor" ) DIM id10 id10 = objApp.CharIDToTypeID( "Angl"...
  • Page 80: Running Javascript-Based Action Manager Code From Applescript

    // Call emboss with values provided in the "arguments" collection emboss( arguments[0], arguments[1], arguments[2] ); 3. The following AppleScript code sample opens a document and runs the Emboss filter on it: tell application "Adobe Photoshop CS4" set theFile to alias “Application:Documents:MyFile” open theFile do javascript (file <path to Emboss.jsx>) ¬...
  • Page 81: Using Scriptlistener To Find Event Ids And Class Ids

    // ======================================================= var id14 = charIDToTypeID( "Opn " ); var desc5 = new ActionDescriptor(); var id15 = charIDToTypeID( "null" ); desc5.putPath( id15, new File( "C:\\Program Files\\Adobe\\Adobe Photoshop CS4\\ Samples\\Fish.psd" ) ); executeAction( id14, desc5, DialogModes.NO ); 4. The executeAction action to take.
  • Page 82 4: Action Manager Using ScriptListener to find event IDs and class IDs 82 HAPTER // ======================================================= var id17 = charIDToTypeID( "Mk " ); var desc6 = new ActionDescriptor(); var id18 = charIDToTypeID( "Nw " ); var desc7 = new ActionDescriptor(); var id19 = charIDToTypeID( "Md "...
  • Page 83 4: Action Manager HAPTER 6. The executeAction . (See "Mk " id17 what class to use, the class ID for the event. 7. The putObject provides us with the class ID that we need. In the first action, putObject the second action, respectively.
  • Page 84: Index

    JavaScript, 75 using from VBScript, 76 actions vs. scripts, 8 working with, 73 Actions palette, 73 active objects, setting, 25 Adobe Photoshop object model, 11, 33 AppleScript conventions, 6 creating, 18 executing JavaScript from, 10 running, 18 unit value considerations, 56...
  • Page 85 Index using, 47 Document object activating, 26 adding, 24 defined, 12 document information, 47 manipulating, 35 opening, 28 relationship to user interface, 14 saving, 31 unit values, 58 using, 34 document object model (DOM), See object model enumerated values finding, 21 EPS open options object, unit values, 58 event IDs, finding with ScriptListener, 81 event notification, setting up, 48...
  • Page 86 11 working with, 33 objects Also see individual objects activating, 25 Adobe Photoshop object model, 11 creating in a script, 23–25 hierarchy, 11 viewing, 21 offset filter object, unit values, 58 Open options classes, 16 parent objects defined, 26...
  • Page 87 Index spot color channels, 13 startup scripts, 10 stroking selections, 44 text, 64 styles, applying to layers, 40 Sub Path Item object defined, 14 text applying color, 64 formatting, 42 layers, 41 stroking, 64 Text Item object creating, 41 defined, 12 formatting text, 42 unit values, 58 working with, 41...

Table of Contents