Copy link to clipboard
Copied
Hi! I can call an ExtendScript script from a command line or batch file just by using its path, but is there a way to pass parameters to the script? Thanks. -Rick
check this out, this might help you!
Copy link to clipboard
Copied
Hi Rick
I answered the question over here Re: Create a build script for Extend Script
I have some more info on it if needed but don't have time to post it this week.
Regards
Trevor
page 11 in the user manual
Automatic jsxbin Conversion
The jsxbin format (Binary JavaScript) enables distributing a script without exposing its source code. The
ExtendScript ToolKit offers an Export to Binary feature that instantly converts a js(x) file into jsxbin. The
jsxbin export process can be done automatically without user interaction.
To do this:
1. Write a compiler script file that compiles .jsx files into a .jsxbin file.
The script file must start with this target directive:
#target estoolkit#dbg
Use the app.compile() method and pass the content of the script file as a String parameter.
In the script, store the result in a new file with the extension .jsxbin.
2. Launch the ExtendScript ToolKit with the command-line parameter -cmd [path to compiler script file]:
Windows:
"ExtendScript Toolkit.exe" -cmd compiler.jsx
Mac:
"ExtendScript Toolkit.app/Contents/MacOS/ExtendScript Toolkit" \
-cmd compiler.jsx
Here is a sample compiler script (compiler.jsx) with the source script's file path hardcoded.
#target estoolkit#dbg
var fileIn = File("/c/jsxbin_test/source.jsx");
fileIn.open("r");
var s = fileIn.read();
fileIn.close();
var t = app.compile(s);
var fileOut = File( fileIn.absoluteURI + "bin" ) ;
fileOut.open("w");
fileOut.write(t);
Copy link to clipboard
Copied
Try this code:
var path = app.scriptArgs.getValue( "indd_path" );
cmd:
sampleclient -host localhost:185 C:\Script\main.jsx indd_path="a.indd"
Copy link to clipboard
Copied
can you elaborate on sampleclient -host localhost:185
Copy link to clipboard
Copied
i using indesign server.
Copy link to clipboard
Copied
sampleclient is used to send a SOAP command to InDesign Server.
While this is an old discussion, let me add this command to cover the Mac side with InDesign Desktop:
osascript -e 'tell application id "com.adobe.indesign" to do script "alert(arguments.toSource())" language javascript with arguments ["Hello", "World"]'
osascript is a shell command to launch an AppleScript.
application id "com.adobe.indesign" is a version independent way to address InDesign.
Copy link to clipboard
Copied
Thanks Dirk
From Windows one can use.
powershell -command "$ind = new-object -comobject InDesign.Application.CC.2018; $ind.DoScript('PathToFile', 1246973031)"
From Mac to run a script File (which can be more convenient) one can use
osascript -e 'tell application "Adobe InDesign CS5" to do script alias "PathToFile" language javascript '''
One question I have is at least on Windows are methods or properties available by connecting directly to the com that are not available from the scripting dictionaries. I.e. are any SDK properties available?
Copy link to clipboard
Copied
Trevor,
The COM interface is described by a "TLB" Type Library. InDesign generates it from the same ScriptInfo resources that it also uses for the AppleScript Terminology, the ExtendScript object model and even for INX and IDML. So in most cases the exposed functionality is the same, with few intentional (extra developer work) differences, e.g. "delete" renamed to "remove" where it collides with a reserved keyword, or properties excluded from a specific engine (not in IDML ...).
I'm not aware of any list of actual differences.
Copy link to clipboard
Copied
Hi Dirk,
I would like to be able to call a script by targeting the the host apps pid
I can tell it to do applescripts but can't tell it to do javascripts
Any ideas of how I can do this?
tell application "System Events"
-- 14883 and 14654 are the PIDs of my running instance of InDesign
set proc to item 1 of (processes whose unix id is 14883)
--set proc to item 1 of (processes whose unix id is 14654)
-- AppleScript works
tell application proc to do script "/Applications/Adobe InDesign CC 2018/Scripts/Scripts Panel/Samples/AppleScript/PathEffects.applescript"
-- javascript doesn't work doesn't let the language to to set to javascript
--tell application proc to do script "/Applications/Adobe InDesign CC 2018/Scripts/Scripts Panel/Samples/JavaScript/PathEffects.jsx" language javascript
end tell
Copy link to clipboard
Copied
Trevor,
"tell application proc" does not work, there is no coercion from process to application.
From error messages with jsx attempts I guess that your AppleScript is still executed because the "tell" will end up at that script's object, and inside the script there'll be another tell to target InDesign. It should also fail with your posix path, but why complain?
Given that all InDesign versions have the same bundle identifier, I see no way to address a specific one by means of "tell". Unfortunately
the Carbon psn seems to be unsupported nowadays, that eliminates other approaches. I'd try to make the process frontmost via System Events, then hope that "tell" prefers that frontmost. Something along
tell application "Finder"
set jsx to (file "test.jsx" of desktop) as alias
set proc to first process whose bundle identifier is "com.adobe.InDesign"
set frontmost of proc to true
tell application id "com.adobe.InDesign" to do script jsx language javascript
end tell
Copy link to clipboard
Copied
Thanks Dirk
That's seems to work well.
I tested it with multiple simultaneous instances of Indesign and it targets the version that it's called from.
My next task it to get it working also on Windows and on the other apps as well.
I'll try work on it in the next month or 2.
Copy link to clipboard
Copied
check this out, this might help you!
Copy link to clipboard
Copied
link is broken?
Copy link to clipboard
Copied
link is broken?
By @jasons46431568
Google "sunil run script from command line adobe forum":
https://community.adobe.com/t5/indesign-discussions/run-script-from-command-line/td-p/10105689