Note sure if I use the appleScript trigger or the URL trigger (which one?)
I searched the forum and could only find the opposite: KBM macro triggering a BTT gesture
thanks in advance for your time and help
I'm not sure how others might be doing it (I might very well be using some hack that is no longer preferred) β but over here, the following works:
1.) After setting up the trigger in BTT;
2.) Under the "Action configurator" in BTT (the part where you tell BTT what must be done when the trigger is fired) >> find the [Controlling Other Applications]/[Execute Terminal Command (Async, non-blocking)] action, and assign it to that trigger;
3.) In the "Enter Terminal Command" field, enter the following:
osascript -e 'tell application "Keyboard Maestro Engine" to do script "65445251-18D0-442A-BEA1-0E098F803D3A"'
Note the quotation marks β all of those must be present, as is, in the above example!
IMPORTANT: The numerical code (the 65445251-18D0-442A-BEA1-0E098F803D3A part) β that is the unique UUID that is associated with the specific KM macro, over in KM.
You need to find it, and insert it into the Terminal Command field, along with the rest, as above.
So...
4.) Over in KM, select the Macro you want to insert/trigger with BTT;
5.) Go to Edit/Copy as/Copy UUID, and click;
6.) The UUID is now in your clipboard β paste that into the Terminal Command field, along with the rest of the script, as above.
Hope that all makes sense!
Let us know if it works!
An excellent reply both in terms of content and format. You must be very intelligent ! Works perfectly.
It took me a while because I setup the script in BBEdit and forgot to take out the hard wrap which invalidates the script as read by BTT.
Thanks very much for your help.
If it's not asking too much: to help me better understand BTT, when I use a terminal script, what is the difference between
Ronald - pleasure - but I'm clearly not that intelligent, since I have no idea what the difference is between the two!
I'm sure somebody here will be able to assist with the answer β there are so many helpful (power)users here that are far more knowledgeable than me when it comes to KM!
I'm just very relieved at being able to help someone else, to pay a bit back for all the help I have received here!
So, very glad to hear that it is working.
thanks again very much.
Hi @ronald, I created a KM macro to make copying and pasting a bit easier.
Please choose the macro you want to run with BTT (blue). Then start this macro:
UUID AS.kmmacros (5,6 KB)
The macro pauses now and you can call the AppleScript action for your BTT trigger. I always use this action in BTT:
Please press the Space key only in the opened field and the KM AppleScript will be inserted.
Here @ronald the identical macro to execute a BTT gesture via a KM macro:
UUID AS.kmmacros (24,1 KB)
Your answer is very well structured. I would say exemplary
I asked the question in the BTT forum, and will let you know if I get a reply.
erstens, thank you very much for the macros.
I spent some time studying them and am still confused (ich bin verwirrt).
voice message: very good idea !! my screen is already overloaded with windows.
- you save the macro UUID to a variable (1) which you later insert into the script (4)
Where I am confused: in BTT Cmd-A (2) highlights my whole menu including description, triggers and actions. Of what use is this ?
Delete (3) does nothing, and Cmd-Delete would simply delete all my BTT triggers which I am sure would not be your intention.
Herzlichen Dank und freundliche GrΓΌΓe
Sorry, my german is bad.
The 2nd one, execute a BTT gesture via a KM macro is clear.
Thank you very much.
I find it useful for some BTT features that I can't find in KBM such as access to the context menu.
That being said, I find myself using BTT less and less and prefer KBM palettes simply because it is too hard to remember BTT gestures. Do you have a system for remembering them ?
thanks again !
When I was younger and less wise, I mapped all kinds of BTT actions to obscure and complicated key combinations to trigger Keyboard Maestro. Then one day (probably a day I was reading this forum) I realized how much easier it is to trigger KBM via this kind of URL: kmtrigger://macro=EB529212-22B3-4106-A840-BAXXXXXDDA31 (the UUID of the macro I want to trigger).
Sooo much more elegant than the covoluted key-chords I'd been mapping before.
I totally agree. It was the impetus for my question.
thank you for your comment
My system @ronald is " learning by doing "
You don't need that many gestures in BTT. I created an inApp palette for all apps (Pages, Mail, DEVONthink, Keyboard Maestro etc).
So I only need one BTT gesture for about 40 apps (3 Finger Swipe right).
If you have created a gesture in BTT and want to use Applescript, you would delete the text in this field (red arrow).
I don't have to do this if you then press the Space key and the KM macro is executed further
thank you very much !
Synchronous/Blocking means that BTT will wait for the command to finish running before firing any subsequent actions. Asynchronous/Non-Blocking means BTT will not wait for the command to finish and fire subsequent actions immediately.
If the terminal command is the only action assigned to your BTT trigger, then it won't matter which one you choose.
If you create a trigger with multiple action steps, you would choose Synchronous if any steps after the command depend on the terminal output or rely on the command completing successfully before continuing on.
thanks very much.
This thread was a top hit when I was searching for invoking a Keyboard Maestro script from Better Touch Tool. I think it's worth noting that you can also use the KM Macro name in the command, which may make it easier to find that using the UUID. I'm using BTT to control my StreamDeck, but I want all of the scripts in KM so that I can have multiple different ways of invoking them, and so I know there's a canonical source for the scripts.
So, the format I'm using (as described in trigger:Script [Keyboard Maestro Wiki]) is
osascript -e 'tell application "Keyboard Maestro Engine" to do script "My Really Cool KM Macro"'
You can also trigger KM by using the Open URL action (kmtrigger://macro=UUID), in BTT.
Cool. Thanks. And this also works with the Macro Name (URL encoded), as described in the URL Schemes KM wik.