Article View: adobe.photoshop.scripting
Article #403Re: Passing arguments to the jsx file from command line
From: Roy_Epperson
Date: Wed, 21 Jan 2009 05:58
Date: Wed, 21 Jan 2009 05:58
39 lines
1882 bytes
1882 bytes
Thanks for to all for the previous posts on getting command line arguments to jsx. I'm using CS3 and post #8 does not work. I generalized another post to have `generic` runjavascript.vbs.
Here's what I came up with.
command line example
runjavascript.vbs c:\mydirectory\test.jsx arg0 arg1 arg2 arg3
Set vbsArguments = WScript.Arguments
If vbsArguments.Length = 0 Then
WScript.Echo "Argument(0) is `your script to execute"
WScript.Echo "Arguments(0+n) are passed to your script as argument(0) to argument(n-1)"
Else
ReDim jsxArguments(vbsArguments.length-2)
for i = 1 to vbsArguments.length - 1
jsxArguments(i-1) = vbsArguments(i)
Next
Set photoshop = CreateObject( "Photoshop.Application" )
photoshop.BringToFront
'DoJavaScript has 3 parameters
' syntax DoJavaScript(arg[0], arg[1], arg[2]]
'arg[0] == javascript file to execute, full pathname
'arg[1] == an array of arguments to past to the javascript
'arg[2] == AiJavaScriptExecutionMode: aiNeverShowDebugger = 1,, aiDebuggerOnError = 2 aiBeforeRunning = 3
' only use 1
Call photoshop.DoJavaScriptFile( vbsArguments(0), jsxArguments, 1)
End IF
#target photoshop
for( n = 0 ; n < arguments.length; n++ ){ alert("argument("+ n+")= " + arguments[n]); }
Technical Details
Message-ID:
<3c05341d.9@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossingReferences:
<3c05341d.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f5839,42c86364a86fbf4 X-Google-Attributes: gidf5839,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Roy_Epperson@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.photoshop.scripting Subject: Re: Passing arguments to the jsx file from command line Message-ID: <3c05341d.9@webcrossing.la2eafNXanI> Date: Tue, 20 Jan 2009 21:58:05 -0800 References: <3c05341d.-1@webcrossing.la2eafNXanI> Lines: 47 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit