Skip to main content
Known Participant
August 25, 2023
Question

Illustrator Script: Pass Variable From Javascript to AppleScript

  • August 25, 2023
  • 2 replies
  • 602 views

Could you please anyone share the codes for below points:

  • Pass variable from Javascript to AppleScript in illustrator file.
  • Pass the arguments from applescript to javascript in illustrator file.
 
This topic has been closed for replies.

2 replies

jduncan
Community Expert
Community Expert
August 25, 2023

There is no good way unfortunately but it can be done. Read this post from the other day to get an idea of a few options.

 

Option A:

  1. write the variable to a file
  2. fire a pre-built applescript with `File.execute()`
  3. read the variable file inside of your applescript and the let applescript do it's work
  4. write the variable you need from applescript to a file
  5. pause in JSX until applescript finishes then read that file to load the variable

 

Option B:

  1. use the clipboard trick from @CarlosCanto to copy the variable to the clipboard in JSX
  2. fire a pre-built applescript that reads the clipboard and does it's work
  3. put the applescript variable in the clipboard
  4. wait in JSX and paste the variable to read it and load into a JSX variable

 

Known Participant
August 25, 2023

Thank you! @jduncan 

Inspiring
August 25, 2023

Communicating from AS to JSX? Ask teh Google:

 

https://www.google.com/search?q=applescript+illustrator+%22do+javascript%22+arguments

 

First hit:

 

https://community.adobe.com/t5/illustrator-discussions/parameter-pass-from-applescript-to-javascript/m-p/11343884#M188394

 

For JSX to AS, you are hobbled by AI’s ExtendScript API. InDesign’s JSX API has a handy:

 

 

Application.doScript(script, [language], [arguments], ...)

 

 

Illustrator’s does not. If you want to AI’s JSX to communicate with outside systems you’ll have to bodge it somehow, e.g. via Google again:

 

https://community.adobe.com/t5/illustrator-discussions/use-command-line-from-illustrator-script/td-p/11110833

Known Participant
August 25, 2023

Thank you! @hhas01