Topics

Use Visual Studio Code (VSC) to Write, Compile, and Run JXA Scripts #script #vsc


 

Great news folks!  An extension for Visual Studio Code (VSC) is available that supports JXA scripts.
See 

AppleScript & JXA - Visual Studio Marketplace 


I've just started testing it, but so far, so good.

If you haven't used VSC, I highly recommend it.  It is free and has great features.  Among them is code completion, which  is far superior to Script Editor.

I hope some of you with join with me in learning and testing the JXA extension for VSC.  Please post your questions, issues, and/or suggestions here.

--
JMichaelTX


 

I've now learned the following:

  1. Note that the extension is named “AppleScript” because it also supports AppleScript. But all you need to do is save a file with a .jxa extension and VSC will auto-recognize it as a JSA script.

  2. To compile and run JXA scripts, open the Command Palette with ⌘⇧P, and type “JXA” to see the choices for it. Or, just use these shortcuts:

    • JXA: Run Script – Shift+Opt+R
    • JXA: Compile Script – Shift+Opt+B
    • But you can easily change these if you prefer other, using Key Bindings for Visual Studio Code
      • I prefer the shortcuts used by both Script Editor and Script Debugger:

        JXA: Run Script – ⌘R
        JXA: Compile Script – ⌘K

  3. Creating .scpt File from .jxa File

    Good news. When you compile/run the .jxa file in VSC, it automatically creates a companion .scpt file, which you will need if you want to run the file from a KM Execute JXA from a file, or via FastScripts.

    image

  4. Opening a .scpt File in VSC

    Short answer is you can’t. You will need to save a text file with a .jxa extension.


That's all for now.
--
JMichaelTX