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

Catching a document open event

  • December 13, 2021
  • 3 replies
  • 1612 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

Brainiac
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
Brainiac
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
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
Brainiac
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
December 13, 2021
quote

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?

 

By @4everJang

 

there might be options, it depends on what "somewhere else" is. Can you describe exactly what your workflow is?

CarlosCanto
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