Get a list of available named triggers

I'm currently trying to use the scripting interface with Raycast to create an extension that will let me run named triggers in BTT.
It would be great if there were a way to access the list of available named triggers from outside of BTT. Seems to me like this could be possible, since some button triggers already have a dropdown with such a list:
Screenshot 2023-02-16 at 20.15.35

A scripting method similar to get_trigger, but for multiple triggers, like get_triggers would be a great solution. Then it would be possible to filter the list and run named triggers on demand.
Apparently I'm not the first person to request this, but I wanted to make a more specific suggestion.
Another cool idea might be a way to get a list of available actions, that would allow even more options (maybe also from Shortcuts)

I have tried the workaround of exporting my preset and parsing the file for BTTTriggerName entries, but this is a manual process and requires multiple steps, which I would like to avoid having to redo everytime I change or add triggers in BTT.

Good idea, I'll add a function to retrieve triggers with some filter options.

1 Like

In 4.026 alpha this would get you all named triggers. This only really works when using Java Script for Automation, because standard Apple Script does not handled JSON well and BTT can only return the data as JSON.

let BetterTouchTool = Application('BetterTouchTool');
let allNamedTriggersJSONString = BetterTouchTool.get_triggers({trigger_id: 643});
let allTriggersJSONArray = JSON.parse(allNamedTriggersJSONString);

let allNamedTriggerNames = [];
for(let trigger of allTriggersJSONArray) {
	allNamedTriggerNames.push(trigger["BTTTriggerName"]);
}

allNamedTriggerNames

The get_triggers() function supports these parameters (all optional):
• trigger_type (e.g. BTTTriggerTypeMagicMouse)
• trigger_id (e.g. 643 for named triggers)
• trigger_parent_uuid (if you want to get the items of a folder)
• trigger_uuid (to get a specific trigger)
• trigger_app_bundle_identifier (to get triggers assigned to a specific app)

The same parameters are now also available on a new function called "delete_triggers()"

//edit: Apple's notary service is currently down, will release the alpha once it's working again

@Andreas_Hegenberg Thank you for implementing my request! I was able to put together the extension with your example code and it works just like I imagined.

Here is my submission for the Raycast store, I hope you're ok with me using the BTT-Logo, otherwise I could probably find a different icon.

3 Likes

nice!

Just created an Alfred workflow as well: GitHub - dnnsmnstrr/alfred-btt: Alfred workflow to run named triggers and actions in BetterTouchTool

2 Likes