Other than pasting code into the Automation Console, how do I .... "use" a script?


I’ve written a basic script, and it works well in the Automation Console window.

I used to be able to drag AppleScripts to the Toolbar to create buttons I could click; how do I use JXA scripts now?

Surely I’ve missed something simple.


There are now two different ways of using JavaScript code to automate recent builds of OmniOutliner

  1. Automation Console scripts are evaluated by the omniJS engine (a JavaScript interpreter embedded in OmniOutliner itself, with a very fast interface to OO)
  2. JXA (JavaScript for Automation) script, which is evaluated in a separate JavaScript interpreter, accessible through Script Editor and shell command lines. JXA uses a slower (Apple Event) interface to the app. (The same interface that AppleScript uses).

It sounds as if what you have written is for the omniJS interface and not for JXA. The main way of executing omniJS scripts is through a hyperlink, and is described here: https://omni-automation.com

There is also a hybrid approach, in which you can get a JXA script or AppleScript to launch the omniJS hyperlink (using the standard additions .openLocation (AS: open location) method).

If you do it this way, you can still put the calling .scpt file on your toolbar.


Oooh – fantastic information.

You’re right – i went the omniJS route (using Sal’s examples), but I use Keyboard Maestro a lot, and have gotten a simple “Hello world.” JXA script to run.

How would I get a handle on my OO document and rootItem from Keyboard Maestro’s JXA interpreter?


Essentially, you create a URL-escaped version of your omniJS code and invoke it with .openLocation() in a Keyboard Maestro execute JXA action.

Here is analogous code for OmniGraffle:


And there is code for JXA here which uses omniJS to read an OO outline, before creating a tree diagram version of it in OmniGraffle.

This could be pasted into a KM JXA action


Awesome – this is what I was missing. Thanks!