Adobe 23102480 Scripting Guide - Page 79

Using ScriptListener to find event IDs and class IDs

Page 79 highlights

Adobe Photoshop CS3 Scripting Guide Photoshop CS3 Action Manager 79 desc7.putInteger( id34, height ); var id35 = charIDToTypeID( "Amnt" ); desc7.putInteger( id35, amount ); executeAction( id32, desc7 ); } 2. At the end of the file emboss.jsx, add the following line of JavaScript code, which executes the emboss function with arguments passed to it from an external invocation. See Introduction to Scripting for more information about passing arguments from a AppleScript to a JavaScript. // 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 CS3" set theFile to alias "Application:Documents:MyFile" open theFile do javascript (file ) ¬ with arguments { 75,2,89 } end tell 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 CS3. 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 72. 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 72) 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 CS3, 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 CS3\\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 ".

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85

Photoshop CS3
Adobe Photoshop CS3
Scripting Guide
Action Manager
79
desc7.putInteger( id34, height );
var id35 = charIDToTypeID( "Amnt" );
desc7.putInteger( id35, amount );
executeAction( id32, desc7 );
}
2.
At the end of the file
emboss.jsx
, add the following line of JavaScript code, which executes the
emboss function with arguments passed to it from an external invocation. See
Introduction to Scripting
for more information about passing arguments from a AppleScript to a JavaScript.
// 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 CS3"
set theFile to alias “Application:Documents:MyFile”
open theFile
do javascript (file <
path to Emboss.jsx
>) ¬
with arguments { 75,2,89 }
end tell
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 CS3. 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 72
. 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 72
) 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 CS3, 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
CS3\\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 ".