Skip to main content
4everJang
Legend
December 13, 2021
Question

Catching a document open event

  • December 13, 2021
  • 3 replies
  • 1650 views

I have done 100s of scripts for FrameMaker, where 170 events are available to have the code react on application and user actions. I did not find any events documentation for Illustrator. Is there anything within ExtendScript to have code activated, e.g. after a document was opened ?

 

If I need another interface to make this work (I found references to ActionScript but these messages were ancient), such pointers would also be useful.

This topic has been closed for replies.

3 replies

Legend
December 20, 2021

The technology behind that "illustrator.executeScript…" snippet is BridgeTalk. The illustrator.something methods are just short wrappers for BridgeTalk calls. There are plenty explanations and examples, I like this one which appears to be close to the original docs that came with ESTK.

https://extendscript.docsforadobe.dev/interapplication-communication/bridgetalk-class.html

 

Then, have a look at "/Library/Application Support/Adobe/Startup Scripts CC/Illustrator 2022/illustrator-20.0.jsx" on your Mac for the actual code. This code should also be present on your Windows machine as soon you install Illustrator, and executed on startup of all ExtendScript hosts including FM.

Copy paste lines 548 thru 579 into your script, eventually uncomment that error handling, then just step thru the mentioned file using the VSCode or ESTK debugger, and watch out for errors.

When using the VSCode debugger, make it connect to Illustrator's targetengine "main" - that's the one processing the "eval" when the BridgeTalk call went thru.

4everJang
4everJangAuthor
Legend
December 20, 2021

Thanks for the detailed explanation and pointer to documents and scripts. I am concentrating on completing the FrameMaker side of the scripting now, but will return to the automation pipeline with Illustrator early next year. I will update this topic when I find the method, so that others can also benefit from my results.

CarlosCanto
Community Expert
Community Expert
December 13, 2021

...but if you open the document with Javascript (not with the illustrator UI), then you can do anything you want before opening.

4everJang
4everJangAuthor
Legend
December 13, 2021

For my application I need to have Illustrator open a specific page from a PDF file and process it to put positioning info of line segments into an XML file. That part of the work is done. Of course this only works when starting the script from Visual Studio Code.

I need a mechanism that makes the script run outside of Visual Studio Code. The main script is driven from another Adobe application (FrameMaker) and determines which page in which PDF document should be opened and processed by the Illustrator script. I was wondering if Bridge would handle this type of inter-application work but it would be easier to just have a script that automatically runs whenever Illustrator is started or opens a document.

So the point is not opening the document with Javascript (I am already doing that from Visual Studio Code) but how to initiate that script from somewhere else. Is there a way to run a script from Windows that launches Illustrator and then runs the script?

 

 

CarlosCanto
Community Expert
Community Expert
December 14, 2021

I tried both methods but neither of them works. The #target is not showing up as legal directive in VSCode, but I ignored that and tried to run the script from FM as you mentioned. No dice. Executing the script via the illustrator.executeScript method did not give any reaction in Illustrator either. I did see that VSCode picked up that line of code and showed it in a new code window, but there was no further action on it.

 

It seems that the inter application support that existed earlier in the ESTK is not or not entirely covered by the VSCode package. But then, when I run the script from FM (i.e. outside of the VSCode debugger) there is no reaction from the AI side, either. No error message from FM on the execute code line, BTW.


that sucks, 

 

did you try the scripts with your current set up, from virtual FM to native OS Illustrator?

CarlosCanto
Community Expert
Community Expert
December 13, 2021

Scripting has no access to Events.

 

there are some events using CEP (soon to be replaced by UXP)

https://github.com/Adobe-CEP

 

and I guess SDK has access to all events