AppleScript Actions -> JavaScript for Automation?

12 views
Skip to first unread message

Nathan Henrie

unread,
Apr 15, 2021, 6:52:36 AMApr 15
to Quicksilver
Hi all,

After a couple days of StackOverflow threads, I can't figure out whether I can use JavaScript for Automation (JXA) in Quicksilver actions.

I have a ton of AppleScript actions, and they're one of the best parts of Quicksilver IMO, but I really hate working with AppleScript. I'm not huge on JavaScript either, but having `map` / `filter` and a more traditional syntax really is a blessing compared to AppleScript. (For context, most of my current AppleScript actions just shell out to python or what have you, which is workable.)

If you open up Script Editor, set the language to JavaScript, then open the Quicksilver dictionary, it *looks* like it supports the same handlers, just with slightly different names (instead of `on process text` it's `processText`).

Unfortunately I've had no luck! I've tried a million or so different configurations of the below.

```
const Quicksilver = Application("Quicksilver")
Quicksilver.includeStandardAdditions = true

function processText(text) {
    return "bar"
}

function openFiles(files) {
    return
}

function getIndirectTypes() {
    return [$.NSStringPboardType]
}

function getDirectTypes() {
    return [$.NSStringPboardType]
}

function getArgumentCount() {
    return 3
}
```
Looking through the source, I don't know enough Obj C to say what the issue may be. I do see `"AppleScript Action: No handler? Aborting..."`` in the logs, and poking around that place in the source and adding a few debug logs, I can see that it isn't finding any handlers in my test file.

Any ideas on this? I'd sure rather be writing these in JS (or python, or go, or swift, or rust, or ...) rather than AppleScript!


Screen Shot 2021-04-14 at 14.33.00.png
Reply all
Reply to author
Forward
0 new messages