Similar to KeyboardMaestro and the Apple Shortcuts App, I would like to be able to link triggers and trigger groups in BTT for later documentation. Therefore, I am currently working on creating the integration scripts.
While BTT provides some scripting identification options (Name, UUID, custom URL Scheme), I am struggling to implement this in the corresponding script. I would be grateful for any assistance. Here is a link to the BTT documentation for reference: https://docs.folivora.ai/docs/1103_custom_url_scheme.html
I can’t find the URL for opening the trigger for editing. I am not familiar with BTT so I post a question here:
If you are OK with a URL with execute_assigned_actions_for_trigger (or you can change it to other available actions), here is the script you can use. Just copy and paste it in Get Address pane for BetterTouchTool.
Get Address Script
use scripting additions
use framework "Foundation"
try
set the clipboard to ""
tell application "System Events" to tell process "BetterTouchTool"
keystroke "c" using {command down}
delay 0.1
repeat 10 times -- poll clipboard for ~1 seconds. Sometimes set x to the clipboard throws exception
try
set selItems to the clipboard
if selItems is not equal to "" then
exit repeat
end if
end try
delay 0.1
end repeat
end tell
set str to current application's NSString's stringWithString:(selItems)
set theData to str's dataUsingEncoding:(current application's NSUTF8StringEncoding)
set {res, theErr} to current application's NSJSONSerialization's JSONObjectWithData:theData options:0 |error|:(reference)
if res is missing value then error (theErr's localizedDescription() as text) number -10000
set aList to res as list
set theUID to BTTUUID of item 1 of aList
set theTitle to BTTTouchBarButtonName of item 1 of aList
return "[" & theTitle & "](" & "btt://execute_assigned_actions_for_trigger/?uuid=" & theUID & ")"
end try