Executing Javascripts From As Or Vbs; Passing As Or Vbs Arguments To Javascript - Adobe PHOTOSHOP CS 2.0 - SCRIPTING GUIDE Manual

Table of Contents

Advertisement

Adobe Photoshop CS2 Scripting Guide
}

Executing JavaScripts from AS or VBS

You can take advantage of JavaScript's platform-independence by running scripts from AppleScript or
VBScript. You can execute either a single JavaScript statement or a complete JavaScript file.
AS
To run a JavaScript from AppleScript, you use the
The following sample executes a single JavaScript command, which displays an alert box with the text
alert text.
do javascript "alert('alert text')"
To pass a JavaScript file, you can create a reference to the file using
as shown in the following examples
file
set scriptFile to "applications: scripts: myscript" as alias
do javascript scriptFile
set scriptFile to a reference to file "applications: scripts: myscript"
do javascript scriptFile
Note:
Refer to an AppleScript language guide or text book for information on referencing a file using
either
VBS
In VBScript, use the
objApp.DoJavaScript ("alert('alert text')")
To open a JavaScript file, use the
drive.
D:\\
Dim appRef As Photoshop.Application
Set appRef = CreateObject("Photoshop.Application")
appRef.DoJavaScriptFile ("D:\\Scripts\\MosaicTiles.jsx")

Passing AS or VBS Arguments to JavaScript

You can also pass arguments to JavaScript from either AppleScript or VBScript using the
arguments/(Arguments)
DoJavaScriptFile
The following examples execute the following JavaScript, which is stored in a file named
your Applications\Scripts folder:
alert( "You passed " + arguments.length + " arguments" )
for ( i = 0; i < arguments.length; ++i )
{
alert( arguments[i].toString() )
}
AS
tell application "Adobe Photoshop CS2"
make new document
do javascript (alias a path to the JavaScript shown above) ¬
or
as alias
to a reference to file
DoJavaScript
DoJavaScriptFile
parameter of the
command or methods. The parameter takes an array to pass any values.
with arguments {1, "test text", (fileApplications:Scripts:JSFile.jsx),¬
current document}
Photoshop CS2
do javascript
.
method to execute a single JavaScript command.
method. The following sample opens a file on the
do javascript/DoJavaScript
Scripting basics
command.
or
as alias
to a reference to
with
or
JSFile.jsx
31
in

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs2

Table of Contents