Skip to main content
Inspiring
March 21, 2015
Answered

How to make Applescript open AI then open file then run ExtendScript then close?

  • March 21, 2015
  • 1 reply
  • 3646 views

Here's the sample Applescript code I came up with using the scripting guide/reference for CS6 and also doing some online searches:

tell application "Adobe Illustrator"

    activate

    delay 10

    set pfilepath to "/Users/username/Documents/Temp/someFile.ai"

    set pfile to POSIX file pfilepath

    open pfile as alias without options

    delay 10

    do javascript "#include '/Users/username/Documents/Temp/someScript.jsx'"

    delay 1

    quit

end tell

I just want to open the app (sample here for AI but also nice to do same for Photoshop), open a file, then run ExtendScript file against it, then close after processing. With this sample script, all that works is the app launches. No file opened, no script ran, app doesn't close at end. I see no errors pop up nor anything show up in command prompt.

The sample ExtendScript just triggers an alert popup message for testing

Also to note, the Applescript snippet is executed from Python but I believe where/how it's executed shouldn't matter (except maybe where the error messages might show up). Although in worse case, I'll debug/run through the AppleScript editor.

Any tips on what's wrong here? Or does it look technically correct?

This topic has been closed for replies.

1 reply

man9ar00AuthorCorrect answer
Inspiring
March 26, 2015
Silly-V
Legend
March 26, 2015

Are you  writing the cross-platform Python application?

man9ar00Author
Inspiring
March 26, 2015

Yes, indeed. On Mac, Python executes the Applescript. On Windows, it invokes the Adobe COM API (in Python rather than the default suggested VBScript). Supposed to be a generic command line script launcher for executing javascript ExtendScripts w/o manually opening/dealing w/ the Adobe apps as well as being able to open a document before executing script as needed for scripts that expect to work against active documents.