Adobe 65048332 Scripting Guide - Page 79

Running JavaScript-based Action Manager code from VBScript

Page 79 highlights

CHAPTER 4: Action Manager Running JavaScript-based Action Manager code from VBScript 79 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" ) Call desc4.PutInteger( id10, angle ) DIM id11 id11 = objApp.CharIDToTypeID( "Hght" ) Call desc4.PutInteger( id11, height ) DIM id12 id12 = objApp.CharIDToTypeID( "Amnt" ) Call desc4.PutInteger( id12, amount ) Call objApp.ExecuteAction( id9, desc4, dialogMode ) End Function 6. Apply the emboss filter script by double clicking on the file emboss.vbs. This launches Photoshop, opens the file and applies the emboss filter to the file. Running JavaScript-based Action Manager code from VBScript You can also access JavaScript-based Action Manager code from a VBScript using the DoJavaScriptFile method. Use the VBscript object browser for more information on the Application.DoJavaScriptFile method. To execute JavaScript-based Action Manager code from a VBScript: 1. Follow steps 1-4 in "Using the Action Manager from JavaScript" on page 75. You will end up with a file (emboss.jsx) containing the following JavaScript code: 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 ); } 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 VBScript to a JavaScript. // Call emboss with values provided in the "arguments" collection emboss( arguments[0], arguments[1], arguments[2] );

  • 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
Running JavaScript-based Action Manager code from VBScript
79
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" )
Call desc4.PutInteger( id10, angle )
DIM id11
id11 = objApp.CharIDToTypeID( "Hght" )
Call desc4.PutInteger( id11, height )
DIM id12
id12 = objApp.CharIDToTypeID( "Amnt" )
Call desc4.PutInteger( id12, amount )
Call objApp.ExecuteAction( id9, desc4, dialogMode )
End Function
6.
Apply the emboss filter script by double clicking on the file
emboss.vbs
. This launches Photoshop,
opens the file and applies the emboss filter to the file.
Running JavaScript-based Action Manager code from VBScript
You can also access JavaScript-based Action Manager code from a VBScript using the
DoJavaScriptFile
method. Use the VBscript object browser for more information on the
Application
.
DoJavaScriptFile
method.
To execute JavaScript-based Action Manager code from a VBScript:
1.
Follow steps 1-4 in
“Using the Action Manager from JavaScript” on page 75
. You will end up with a file
(
emboss.jsx
) containing the following JavaScript code:
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 );
}
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 VBScript to a JavaScript.
// Call emboss with values provided in the "arguments" collection
emboss( arguments[0], arguments[1], arguments[2] );