Adobe 23102480 Scripting Guide - Page 74

Using the Action Manager from JavaScript, To create a JavaScript from the ScriptListener output

Page 74 highlights

Adobe Photoshop CS3 Scripting Guide Photoshop CS3 ● On Mac OS, the log files are on the desktop. Action Manager 74 Using the Action Manager from JavaScript The section demonstrates how to use the contents of the ScriptingListenerJS.log log to create your script. Before you begin this section, you need have already recorded an action. The example in this section assumes you have followed the instructions in 'Recording a Script using ScriptListener' on page 73. The procedures in this section use the Action Manager to make the Emboss filter available to the scripting interface. ➤ To create a JavaScript from the ScriptListener output: 1. Do one of the following: ● Open ScriptingListenerJS.log on the desktop. At the end of the file you will see code similar to the following (although your numbers may be different): var id19 = charIDToTypeID( "Embs" ); var desc4 = new ActionDescriptor(); var id20 = charIDToTypeID( "Angl" ); desc4.putInteger( id20, 135 ); var id21 = charIDToTypeID( "Hght" ); desc4.putInteger( id21, 3 ); var id22 = charIDToTypeID( "Amnt" ); desc4.putInteger( id22, 100 ); executeAction( id19, desc4 ,DialogModes.NO); Note: ScriptListener separates logged commands with horizontal lines composed of equal signs If this is not the first action recorded in the log, you can easily locate the most recent action; it follows the final equal sign line. 2. Copy the JavaScript code associated with the emboss action from ScriptListenerJS.log to another file, called emboss.jsx. 3. In the emboss.jsx script, identify the values that you used with the filter (135, 3 and 100). Substitute the filter specification values with variable names. In the following example, 135 has been replaced with angle; 3 has been replaced with height; 100 has been replaced with amount. var id19 = charIDToTypeID( "Embs" ); var desc4 = new ActionDescriptor(); var id20 = charIDToTypeID( "Angl" ); desc4.putInteger( id20, angle ); var id21 = charIDToTypeID( "Hght" ); desc4.putInteger( id21, height ); var id22 = charIDToTypeID( "Amnt" ); desc7.putInteger( id22, amount ); executeAction( id19, desc4,DialogModes.NO ); 4. Wrap the code in a JavaScript function. In the following example, the function name is emboss. function emboss( angle, height, amount ) { var id19 = charIDToTypeID( "Embs" ); var desc4 = new ActionDescriptor(); var id20 = charIDToTypeID( "Angl" );

  • 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
74
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
ScriptingListenerJS.log
log to create your
script. Before you begin this section, you need have already recorded an action. The example in this
section assumes you have followed the instructions in
‘Recording a Script using ScriptListener’ on page 73
.
The procedures in this section use the Action Manager to make the Emboss filter available to the scripting
interface.
To create a JavaScript from the ScriptListener output:
1.
Do one of the following:
Open
ScriptingListenerJS.log
on the desktop.
At the end of the file you will see code similar to the following (although your numbers may be
different):
var id19 = charIDToTypeID( "Embs" );
var desc4 = new ActionDescriptor();
var id20 = charIDToTypeID( "Angl" );
desc4.putInteger( id20, 135 );
var id21 = charIDToTypeID( "Hght" );
desc4.putInteger( id21, 3 );
var id22 = charIDToTypeID( "Amnt" );
desc4.putInteger( id22, 100 );
executeAction( id19, desc4 ,DialogModes.NO);
Note:
ScriptListener separates logged commands with horizontal lines composed of equal signs
(=====...). If this is not the first action recorded in the log, you can easily locate the most recent
action; it follows the final equal sign line.
2.
Copy the JavaScript code associated with the emboss action from
ScriptListenerJS.log
to another
file, called
emboss.jsx
.
3.
In the
emboss.jsx
script, identify the values that you used with the filter (135, 3 and 100). Substitute
the filter specification values with variable names.
In the following example,
135
has been replaced with
angle
;
3
has been replaced with
height
;
100
has
been replaced with
amount
.
var id19 = charIDToTypeID( "Embs" );
var desc4 = new ActionDescriptor();
var id20 = charIDToTypeID( "Angl" );
desc4.putInteger( id20, angle );
var id21 = charIDToTypeID( "Hght" );
desc4.putInteger( id21, height );
var id22 = charIDToTypeID( "Amnt" );
desc7.putInteger( id22, amount );
executeAction( id19, desc4,DialogModes.NO );
4.
Wrap the code in a JavaScript function. In the following example, the function name is
emboss
.
function emboss( angle, height, amount )
{
var id19 = charIDToTypeID( "Embs" );
var desc4 = new ActionDescriptor();
var id20 = charIDToTypeID( "Angl" );