Adobe 23101335 - Photoshop - PC Manual page 49

Scripting guide
Hide thumbs Also See for 23101335 - Photoshop - PC:
Table of Contents

Advertisement

For Visual Basic, use either the Application's DoJavaScript or DoJavaScriptFile
method. DoJavaScript takes a string, which is the JavaScript code to execute.
DoJavaScriptFile opens a file that contains the JavaScript code. An example is below:
AS:
set scriptFile to "myscript" as alias
do javascript scriptFile
VB:
Dim appRef As Photoshop.Application
Set appRef = CreateObject("Photoshop.Application")
appRef.DoJavaScriptFile ("D:\\Scripts\\MosaicTiles.js")
3.6.1 Passing arguments to JavaScript
You can pass arguments to JavaScript from either AppleScript or Visual Basic by using the
with arguments (Arguments) parameter. The parameter takes an array for you to pass
any values.
For example, save the following JavaScript in a file somewhere on your machine:
alert( "You passed " + arguments.length + " arguments" );
for ( i = 0; i < arguments.length; ++i )
{
}
To pass arguments from AppleScript try this:
tell application "Adobe Photoshop 7.0"
end tell
To do the same thing in VB, write:
Dim appRef As Photoshop.Application
Set appRef = CreateObject("Photoshop.Application")
appRef.DoJavaScriptFile "C:\scripts-temp\test.js", _
When running JavaScript from AppleScript or Visual Basic you can also control the
debugging state. To do this you use the show debugger (ExecutionMode) argument. The
values of this argument include:
Photoshop 7.0 Scripting Guide
alert( arguments[i].toString() )
make new document
do javascript (alias <a path to the JavaScript shown above>) ¬
with arguments {1, "test text", (file <a path to a file>),¬
current document}
Array(1, "text text", appRef.ActiveDocument)
Scripting Photoshop
Executing JavaScripts from AS or VB
3
49

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop 7.0

Table of Contents