Adobe 65014293 Scripting Guide - Page 76

Using the Action Manager from a VBS Script

Page 76 highlights

CHAPTER 4: Action Manager Using the Action Manager from a VBS Script 76 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" ); 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); } 5. To use a JavaScript to apply the Emboss filter to a document, include the emboss function in the JavaScript and call the function with the desired parameters. For example, the following example applies the Emboss filter with angle 75, height 2, and amount 89. (See "Opening a Document" on page 28, for help in writing the code to open a document within the script.) // Open the document in the script var fileRef = new File("/c/myfile") var docRef = app.open(fileRef) //Call emboss with desired parameters emboss( 75, 2, 89 ); //finish the script //include the function in the script file function emboss(angle, height, amount ) { var id32 = charIDToTypeID( "Embs" ); var desc7 = new ActionDescriptor(); var id33 = charIDToTypeID( "Angl" ); desc7.putInteger( id33, angle ); var id34 = charIDToTypeID( "Hght" ); desc7.putInteger( id34, height ); var id35 = charIDToTypeID( "Amnt" ); desc7.putInteger( id35, amount ); executeAction( id32, desc7,DialogModes.NO ); } 6. Open Photoshop, to apply the emboss filter by selecting File > Scripts > Browse, and then browsing to the location of your emboss.jsx script. Select Open to run the script. Using the Action Manager from a VBS Script The section demonstrates how to use the contents of the ScriptingListenerVB.log log to create your script. Before you begin this section, you need to have already recorded an action. The example in this section assumes you have followed the instructions in "Recording a Script using ScriptListener" on page 74. The procedures in this section use the Action Manager to make the Emboss filter available to the scripting interface.

  • 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
  • 86
  • 87

C
HAPTER
4: Action Manager
Using the Action Manager from a VBS Script
76
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" );
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);
}
5.
To use a JavaScript to apply the Emboss filter to a document, include the emboss function in the
JavaScript and call the function with the desired parameters. For example, the following example
applies the Emboss filter with angle 75, height 2, and amount 89. (See
“Opening a Document” on
page 28
, for help in writing the code to open a document within the script.)
// Open the document in the script
var fileRef = new File("/c/myfile")
var docRef = app.open(fileRef)
//Call emboss with desired parameters
emboss( 75, 2, 89 );
//finish the script
//include the function in the script file
function emboss(angle, height, amount )
{
var id32 = charIDToTypeID( "Embs" );
var desc7 = new ActionDescriptor();
var id33 = charIDToTypeID( "Angl" );
desc7.putInteger( id33, angle );
var id34 = charIDToTypeID( "Hght" );
desc7.putInteger( id34, height );
var id35 = charIDToTypeID( "Amnt" );
desc7.putInteger( id35, amount );
executeAction( id32, desc7,DialogModes.NO );
}
6.
Open Photoshop, to apply the emboss filter by selecting
File > Scripts > Browse
, and then browsing
to the location of your emboss.jsx script. Select
Open
to run the script.
Using the Action Manager from a VBS Script
The section demonstrates how to use the contents of the
ScriptingListenerVB.log
log to create your
script. Before you begin this section, you need to have already recorded an action. The example in this
section assumes you have followed the instructions in
“Recording a Script using ScriptListener” on
page 74
.
The procedures in this section use the Action Manager to make the Emboss filter available to the scripting
interface.