You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally published in my dotfiles repository (Alhadis/.files@53106ec0), but posted as a standalone Gist for greater by search engines, and thus better discoverability by whoever needs documentation on a subject this niche.
followed by RFC 3986-compliant query variables of the form used by regular web
addresses. Supported parameters are documented below; unrecognised parameters
are presumably ignored by the handler application (Script Editor).
Using no parameters is also legal, and merely instructs Script Editor to open an
empty window analogously to action=new.
AppleScript source code to send to the script-editor. The presence of this
parameter on newer systems may trigger a security prompt requesting the user
give permission to create a new script, ostensibly rendering the action
parameter meaningless.
directory
Directory that new scripts are to be saved to. If the specified disk location
doesn't exist when the editor's "Save" dialogue is opened, it will be created
automatically.
appid
If present, the new script is treated as an application script for a program
with the given identifier string. The default save location will be inside a
directory created under ~/Library/Application Scripts named after the app-ID.
For example:
As with the directory parameter, nonexistent directories (along with any
intermediate directories) are created automatically when the script-editor
prompts for the user to select a location to save to.
References
Research for this document was based on the following resources, listed
chronologically in the order I originally discovered or consulted them:
A MacScripter discussion on the `[applescript]` tag:
Running the strings(1) command extracts raw text embedded in a binary file (in this case, the actual executable
of the Script Editor application), Extracted strings are printed line-by-line, prefixed by their hex-encoded
byte offsets:
Here, we filter the results down to strings that fully-match the word applescript case-sensitively, in its entirety,
along with the previous and next 8 lines (which helps identify clusters of contiguous strings with possibly shared usage).
In our case, the aforementioned strategy worked, and revealed two adjacent strings that hinted at a URL handler:
applescript (the URL scheme) and com.apple.scripteditor (the URL's pathname). The strings that followed were
mentioned in sources 1 and 2, but two of them weren't: appid and directory. After some experimentation,
these were confirmed to be undocumented parameters that influence the behaviour of Script Editor in highly-specific
(and decidedly unhelpful) ways. Nonetheless, I felt impelled to document my findings somewhere, and was my imperative
for penning this entire deep-dive.
Footnotes
The trailing slash after com.apple.scripteditor is technically optional,
but its omission has reportedly caused portability issues with BBCode markup
(formerly macscripter.net2) and possibly other websites and applications.
To ensure consistent behaviour and handling, always include the slash when
writing your AppleScript URLs: com.apple.scripteditor/↩
Some message boards,
such as macscripter.net, require alternate URL formats
for embedding links in forum messages.2Apple, op. cit.↩