Adobe 65014293 Scripting Guide - Page 81
Using ScriptListener to find event IDs and class IDs
UPC - 883919153544
View all Adobe 65014293 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 81 highlights
CHAPTER 4: Action Manager Using ScriptListener to find event IDs and class IDs 81 Using ScriptListener to find event IDs and class IDs The section demonstrates how to use ScriptListener to determine event IDs and class IDs for actions taken by Photoshop. These event and class IDs are used to set up notification using the Notifier class. You can determine the event ID for any recordable action by using ScriptListener. Simply install the ScriptListener plug in, as described in "Installing ScriptListener" on page 73. Then execute the action you want to find the event ID for. The event is logged in the Script Listener log file. (See "The ScriptListener Plug-In" on page 73) If the event applies to several different classes of objects, the class ID is also logged in the log file. The following examples show how to find the event ID for the "Open Document" event, and the event and class IDs for the "New" event, which applies to several different classes. Finding the event ID for the "Open Document" event 1. Make sure that the ScriptListener plug in is installed. 2. Open Photoshop, then open a document. 3. Find the ScriptListener log file and open it. You can use either the VBScript log file or the JavaScript log file. In the JavaScript version of the file, you will see code that looks something like this at the end of the file, everything below the row of equal signs the log of the last action taken: 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 method runs the action from a script, and it needs the event ID to identify which action to take. The first argument, in this case id14, provides the event ID to the method. You can see the variable id14 defined several lines earlier, and it shows that the event ID for the Open Document action is "Opn ". 5. You can now use this event ID to set up event notification on Open Document from your scripts. In JavaScript, for example: var eventFile = new File(app.path + "/Presets/Scripts/Event Scripts Only/Welcome.jsx") app.notifiers.add( "Opn ", eventFile) Finding the event ID and class ID for the "New" event 1. Make sure that the ScriptListener plug in is installed. 2. Open Photoshop, then create a new document using File > New. 3. Next, create a new channel, using the Create New Channel icon on the Channels palette. 4. Find the ScriptListener log file and open it. You can use either the VBScript log file or the JavaScript log file. We have recorded two actions, so we are interested in looking at the last two sections in the file that are delimited by the rows of equal signs. In the JavaScript log file, you will see code that looks something like this: