Is there any way to toggle apps ?

I would like a gesture to activate (for example) an app tif it is not active and the front window, but to hide or close if it is already active and at the front.
I commonly use this with keyboard maestro macros.
thank you

If you have such a macro in KM, you can trigger it with a BTT gesture.

thank you. i know that. I was asking if it's possible with BTT.

I think the "Show/Hide Specific Application" action (with default configuration) might do what you want.

1 Like

That's nice. I did not know this action. I learned something new. I just wanted to point out that BTT and KM work well together and that many trigger their (complex) macros from KM through BTT. :slight_smile:

Yep, same goes for the macOS Shortcuts app, which got much faster in recent macOS versions. Many ways to achieve automation nowadays :slight_smile:

thank you Andreas. Exactly what I was looking for.

Hi @Frank1
I just wanted to say that I very much appreciate the time and energy you put into answering my question. You are right that I can trigger KM macros. Had I not known it would have been a very helpful suggestion. I don't want you to think that I was dismissing your answer. Have a nice day.

No problem, if I had known that there was a predefined action in BTT, that would have been the bigger help. :rofl: :joy:

1 Like

is this the script you use to trigger a KM macro ? thank you

BTT action is Execute Terminal Command, Asynchronous and the script is:

osascript -e 'tell application "Keyboard Maestro Engine" to do script "2431E762-6369-4D03-B070-063FB1C631BF"'

I assume you mean me? Coincidentally, I also use a show/hide macro in KM because I didn't know BTT has a predefined action for it. I just used a shortcut in KM that I would never use otherwise. Then I trigger this shortcut with a key sequence in BTT: double tab the right shift key.

So this


Triggers this
image

Was that your question or did I misunderstand you? :slight_smile:

It's a little faster to use the "Run Apple Script (async in background)" action instead of the terminal action.

I meant what kind of script do you use in BTT to trigger the KM macro. AppleScript or Shell Script ?

It's funny. I have multiple instances where the AppleScript does not work, and I use the shell script. Don't know why.

Mm, I trigger the macro exactly as explained above :man_shrugging:

1 Like

OK thanks

Curious why you use the "double tab the right shift key" in BTT for this, instead of setting KM shortcut for the "macro" to just be "double tap the right shift" instead of the one "would never use otherwise?"

Sidenote: I don't have KM, so I'm not sure of its limitations.

This is a valid question and leads to the differences between KM and BTT. KM does not offer the same possibilities with Key Sequences as BTT. I could use a normal shortcut "cmd + something“ in KM but I use that so often that I want something simpler. "double tab the right shift key" is simple but not possible in KM. That's why I made this workaround. I do this whenever I have to set up a macro in KM that is not possible in BTT.

"the one I would never use otherwise": This is only about preventing conflicts. BTT is supposed to pass a shortcut to KM that is not used otherwise. This works perfectly, which is why I don't understand why people want to do this with complicated scripts that don't work.

Of course now that I know that BTT has a predefined action for "show/hide app", I will set up this action in BTT directly :slight_smile:

Ah, okay, makes sense.

I've heard many things about KM, however never gave it a personal try. I read through their docs a while back, but didn't find anything that it could do, that I couldn't already do with either BTT, Alfred, or a little of MacOS built in Automator/Scripting. So I figured why add another app running in the background if it wasn't absolutely necessary.

Regarding that "Show/Hide Specific App" Trigger, I noticed that it states that the default behavior is to switch to only the last used window, which is awesome. I was wondering if there is a way to set the specific app to always be the previously used app? This would allow a command-tab-like behavior that switches to the last app, but without bringing all of the apps windows to the front (such as switching to safari brings all window to the front, which is how command-tab behaves by default, which I always find annoying).