Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Script opens in editor instead of running?

edited January 2014 in FastScripts
Brand new user, and I'm trying to run my first script. It's JavaScript that's supposed to execute in Illustrator, but when I try to run the script via FastScripts it opens the script in my script editor (TextWrangler) instead of executing the script.

The script shouldn't be broken, because when I try to run it through the Illustrator menu it works perfectly.

FastScripts is "scripting language agnostic", but I can't find anything confirming nor denying that it works with JavaScript. Is JavaScript the issue?

Additional details: I'm on Mac OS 10.9.1, Illustrator CS6.

Thanks in advance!


  • Accepted Answer
    Hi there - FastScripts will run a variety of scripting languages, but only if the scripts are either AppleScript or will run as standalone scripts on the command line (e.g. a scripting language like perl, python, sh, bash, etc that can be invoked from the command line). Unfortunately for this kind of JavaScript-based script that is especially suited to Illustrator, it might not fit the bill.

    Since FastScripts is running the script outside of the targeted app, it has to be able to make sense of the script independently of the app.

    That said, I wouldn't be surprised if the JavaScript code could be packed up into an AppleScript that asks Illustrator to run the JavaScript. Do you have any experience with writing AppleScripts for Illustrator? I am wondering if it supports an AppleScript command like "do javascript" that would be useful for running arbitrary scripts from outside the app.
  • Hi Daniel,

    That confirms my suspicions. Thank you for the clear explanation!

    I have a novice-level understanding of AppleScript, and I do believe there is a way to trigger a JavaScript via AppleScript. I'll do some digging around and see what I can find.

    Thanks again!
  • Great - let us know if you find a solution, or if there's anything else I can do to help.
  • You need to set the "open with" property of the JSX to "" (whichever version you're using).

    Use the finder info panel (CMD+i) to change that property of the script.
  • Great idea, nimbling! Thanks.
  • -- pr_options.scpt or other names (like -, sounds so-oh sweet!
    -- How about a (do shell script) solution....
    -- Imagine other (753 here on my mac) commands at the unix command line expanding your MarsEdit
    -- capabilities, like this BASH offering, below. Written in this manner to run as an
    -- Applescript .scpt file.
    -- English can be listened to by a French man.

    -- Why not Apple - OS X - linux -unix - iWorks Pages, Numbers, *.app's, etc., etc.,
    -- Reading and writing a .scpt file that reads system events and selects the nearest
    -- default printer for printing operations, if it is online and ready.

    on print_lpr(thePath, thePrinter)
    -- do shell script pr_options
    do shell script "lpr " & "-P " & thePrinter & space & (quoted form of POSIX path of thePath)
    return true
    on error
    return false
    end try
    end print_lpr

    -- What do you know about IP6?
  • edited November 15
    Possibly relevant to this thread - I haven't yet played around with JXA (Javascript for Automation) on either Yosemite (when it was introduced) or El Capitan, but I might. Info here:

    At this stage, with JXA now considered "a peer" of AppleScript - at least by Script Editor - do you think JXA scripts that run OK in Script Editor, will also run fine when invoked by FastScripts?
  • Yes, as a rule a JXA script should run fine in FastScripts! Let me know if you run into any problems.
Sign In or Register to comment.