How to trigger different shortcuts based on which app is using the microphone?

I’m trying to set up a single shortcut in BetterTouchTool that behaves differently depending on which application is currently using the microphone.

My goal is to bind Command + M to:

  • Detect which app is actively using the microphone

  • Then execute a “Shortcut to specific app” for that app

The use case is muting/unmuting calls, because different apps use different keybinds:

  • Microsoft Teams: Command + Shift + M

  • Slack: Command + Shift + Space

Ideally, when I press Command + M:

  • If Teams is using the microphone → trigger Command + Shift + M

  • If Slack is using the microphone → trigger Command + Shift + Space

    Is there a way in BTT to detect which app is currently using the microphone and execute an action based on it?

Take a look at this thread:

I think this does what you want.

In that discussion, there are two different ways of getting BTT to run a terminal command to detect whether a meeting app is active, and if so, which one.

This is the solution I came up with. It works, but I wonder if there is a more elegant way, for example with if conditions or something else.