0

Investigating Electron at the moment, with ultimate aim of controlling actions/scripts in other apps (like InDesign).

Currently part of my workflow uses Filemaker to trigger applecripts that control actions/alter InDesign docs (and then feedback results through AppleScript to filemaker).

Would it similarly be possible with Electron - i.e. trigger an event in Electron (through user action or watched folder etc) that would then use electron/JavaScript to “tell InDesign” to do some action and get feedback to trigger further actions in Electron?

1 Answers1

0

I have not used Electron but we did some development with nwjs, which is similar. The way we set it up is by having nwjs execute VBS files (which is possible on Windows with command line executable CScript or WScript. I'm not sure about MAC or Linux). VBS files either contained the script directly to run in InDesign or used a vbs DoScript command to run an external jsx files or even a combination thereof. An external JSX files apparently can't be run directly in InDesign without ExtendScript or VBS.

In summary: NWJS -> VBS (-> JSX) -> InDesign.

Capturing response was a bit of a hassle because there is no direct way (I know of) to capture when the jsx is done running in InDesign. But we used 2 different approaches - one was to capture responses in an external database (and have NWJS read the DB until the script was done) and the other to simply create a file in a TEMP location and have NWJS wait for it to appear. Unfortunately neither of those are asynchronous so if you need something more dynamic, it will need more work.

Michael
  • 75
  • 9
  • Thanks for that. Sound similar to our current approach with Applescript. Applescript has the advantage of performing actions across multiple applications and getting a response/values from each and passing between. I'm just trying to make us more platform independent ;-) and was hoping could get Electron js to speak to InDesign js (without intermediate/intermediary of system dependent VB or Applescript)... – mrvmonkey Nov 14 '19 at 10:49
  • I thought of another way, which is platform-independent. You could use ExtendScript and call it externally. Both MAC and WIN support that. See https://stackoverflow.com/questions/37320580/how-to-execute-an-indesign-extendscript-from-command-line. All you need to do is to put "#target InDesign-10 (or whatever version you are running) at the top of the script for it to know that you will run it in InDesign. In summary: Electron will call a command line or a terminal command to execute an ExtendScript with a -run parameter and your script. Unfortunately I can't test it on MAC. – Michael Nov 14 '19 at 22:53
  • Thanks - I'll try that tomorrow and let you know how I get on – mrvmonkey Nov 18 '19 at 18:53
  • Bah - didn't work - opens the script in extend script toolkit application... Will try some other variations... (Those links complain about same problem and then point back to using applescript/VB script to launch / do the tell application part – mrvmonkey Nov 19 '19 at 14:00
  • A couple of things to know: 1) make sure your script name if it has spaces is in quotation marks. 2) The version of InDesign should be correct after #target. I used this script (I'm on WIN7 with CC2014): #target InDesign-10 app.doScript(function(){alert('ok')}); and called it with this line: "C:\Program Files(X86)\Adobe\Adobe Utilities\ExtendScript\ExtendScript.exe" -run "C:\temp\my script.jsx". This worked without getting Extendscript UI opening. – Michael Nov 20 '19 at 01:01