Skip to main content
Inspiring
June 16, 2021
Question

Load CEP from javascript file

  • June 16, 2021
  • 2 replies
  • 2408 views

I'm running a javascript file from apple script.

I would like to load CEP from the js file.  Here is what I'm attempting to do but it's not working.  I'm getting this error:

Adobe Illustrator got an error: Error 2: window is undefined.

First I load my js file in illustrator like so:

 

set jsFilePath to POSIX file "/Library/Application Support/Adobe/CEP/extensions/CEP_HTML_Test_Extension-9.0/js/autoRunTemplates.js"

tell application "Adobe Illustrator"
	launch
	do javascript jsFilePath
end tell

 

 Then I attempt to load the CEP file.  (Normally I load this in html).

 

function runScript() {
  #include './CSInterface.js'
}

runScript();

 

My goal is to run a javascript file from apple script to run some CEP type scripting in illustrator.

This topic has been closed for replies.

2 replies

OhmsGAuthor
Inspiring
June 16, 2021

Ok it makes complete sense.  I need to run a CEP task from Apple script.  My idea was to run a javascript file and then execute the CEP from the js file.  How can I launch the CEP html from an apple script command?

Inventsable
Legend
June 16, 2021

What CEP task? This may be an XY problem. I'm asking what you're trying to accomplish but you only tell me what your proposed solution is, not saying the intent of that solution or the original problem.

OhmsGAuthor
Inspiring
June 16, 2021
In CEP i have different tasks that I run using the html CEP. In example
setting up some illustrator files. I need to set this on a timer to run
every night. My solution was to do this via apple script and then have it
automate the CEP tasks. This is why I thought running the CEP through
javascript would work. The exact tasks vary but ultimately it's clicking a
button on the CEP that runs the CEP scripts.
Inventsable
Legend
June 16, 2021

I don't understand what you're trying to do here. You cannot run CEP from scripting, you can only run scripting from CEP. Window is a global object that only exists in an HTML environment which is scoped to an existing CEP extension.

 

What is your goal? CSInterface does not work in scripting. It's a shim for an HTML environment to have aliases to communicate with the app. What are you trying to use CEP for, instead of telling us you're trying to use CEP?