Skip to content

Custom AppleScript actions: support JavaScript for automations (JXA) #2604

@n8henrie

Description

@n8henrie

Copied from: https://groups.google.com/g/blacktree-quicksilver/c/I6dkTGN0bI8/m/ebbi1s46AAAJ

Low priority. I will take another look at this after 1.7.0


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!

image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions