Join GitHub today
The Lie Of The Land
Stuff you need to understand
When automating a Creative Cloud app, you need to navigate two superficially similar environments.
One one hand, there is an ExtendScript interpreter which is deeply embedded into the Creative Cloud app (InDesign, Illustrator, Photoshop...)
ExtendScript: Inward Facing
ExtendScript is 'inward facing': its main purpose in life is to manipulate the Creative Cloud document.
ExtendScript has some UI (User Interface) features, but they are very limited.
The ExtendScript engine is deeply integrated into the Creative Cloud app. It has access to a DOM (Document Object Model) that represents the documents managed by the app.
Each Creative Cloud app has a slightly different ExtendScript engine with a slightly different feature set.
Each Creative Cloud app has a very different ExtendScript DOM. For example, an InDesign document is very different than an Illustrator document. One has 'spreads', 'pages', 'paragraphs',... the other has 'artboards', 'layers',...
All of these engines are quite similar in many respects, but each has its own idiosyncrasies.
When you run an ExtendScript, it will run in the apps own process.
If you inspect the task list or process list on your computer when you run an ExtendScript you won't see any new process IDs being spun off to run the script.
Running ExtendScript is a synchronous process: the app is non-responsive while the ExtendScript runs.
This UI is then captured and shoehorned into a panel or dialog which in turn is managed by the app.
The app manages the 'frame' of the UI (e.g. as a panel, as a dialog...)
These calls can be either to the ExtendScript engine, or possibly to some native C++ code buried in some plug-in buried deep into the app.
Points of Confusion
In this complicated picture there is a lot of room for confusion:
- One of the engines is asynchronous and detached from the app, the other is synchronous and embedded in the app
- One of the engines is single-threading: while you run an ExtendScript the app becomes unresponsive. The other engine lives in a separate process, and only interacts with the app via asynchronous calls and callbacks.
- One of the engines is inward facing, the other is outward facing