Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7192861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:02:32+00:00 2026-05-28T20:02:32+00:00

Typically when you’re writing a .jsx script to automate an Adobe product (like InDesign,

  • 0

Typically when you’re writing a .jsx script to automate an Adobe product (like InDesign, Illustrator or Photoshop), you write, debug and execute the script from the ExtendScript IDE. Is it possible to bypass ExtendScript and run the script from a third program?

I think Adobe products have a built-in JavaScript interpreter which ExtendScript can connect to to access the Adobe object models and automate their software. I’d like to be able to connect directly to that interpreter and run jsx files just as I would in ExtendScript.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:02:33+00:00Added an answer on May 28, 2026 at 8:02 pm

    Are you on a Mac? If so, you can use AppleScript with the osascript tool to execute your JavaScript. Here are some examples:

    Running JSX and Returning a Value

    Save this as ~/temp/foo.scpt:

    tell application "Adobe Illustrator"
         -- 'do javascript' runs any arbitrary JS.
         -- We're using the #include feature to run another
         -- file. (That's an Adobe extension to JS.)
         --
         -- You have to pass a full, absolute path to #include.
         --
         -- The documentation alleges that 'do javascript'
         -- can be passed an AppleScript file object, but
         -- I wasn't able to get that to work.
         do javascript "#include ~/temp/foo.jsx"
    end tell
    

    And save this as ~/temp/foo.jsx:

    var doc = app.activeDocument;
    var numLayers = doc.layers.length;
    
    // The last value in the JSX file will be printed out by
    // osascript. 
    numLayers;
    

    Now, from the command line run osascript ~/temp/foo.scpt It will print the number of layers in the active Illustrator document.

    Getting data out of the JavaScript is limiting. You can’t print to stdout from within the JavaScript. Instead, place the value you want to return as the last statement of the JSX file; it will be printed by osascript. (Here’s why: The last value in the JSX file is the return value of the do javascript AppleScript statement. That is also the last value in the AppleScript file, and osascript prints the final value.)

    The value you return from JavaScript can be a number, a string, an array, or anything else that retains its value when converted to a string. If you want to return a complex object, you’ll need to #include a JSON library and call .toJSONString() on the object.

    Passing Arguments to JSX

    To pass arguments to the JSX code, follow this example:

    File ~/temp/args.scpt:

    on run argv
        tell application "Adobe Illustrator"
            set js to "#include '~/temp/args.jsx';" & return
            set js to js & "main(arguments);" & return
            do javascript js with arguments argv
        end tell
    end run
    

    File ~/temp/args.jsx

    function main(argv) {
        var layer = app.activeDocument.activeLayer;
        app.defaultStroked = true; 
        app.defaultFilled = true;
    
        // Top, left, width, height (in points).
        // Note that parameters start at argv[0].
        layer.pathItems.rectangle(argv[0], argv[1], argv[2], argv[3]);
    }
    

    And then run osascript args.scpt 50 30 10 80

    Debugging

    The do javascript command also has options for launching the ExtendScript debugger. For details, open the Illustrator dictionary in AppleScript Editor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Typically I have to write layout code like this: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical
I typically write something like this: class Person < ActiveRecord::Base attr_accessible :first_name, :last_name def
Typically when writing new code you discover that you are missing a #include because
Typically you will find STL code like this: for (SomeClass::SomeContainer::iterator Iter = m_SomeMemberContainerVar.begin(); Iter
Typically when doing a build script for C# I just include **/*.cs for each
typically the code is something like: <html> <head> <style type=text/css> body { font-size:12pt; font-family:
typically when you refer to an object you would use a selector like this
I typically have code like this on a form: private void PerformLongRunningOperation() { BackgroundWorker
typically definition of property/column looks like this: <property name=DocumentSummary column=DocumentSummary length=100 type=String> <column name=DocumentSummary
Typically I do something like: q = Queue() p = Process(target=f, args=(q,)) p.start() Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.