Hide App if active (Dock Widget)

Currently, clicking on an active app does nothing. It will be nice if you could hide an active app by clicking its icon on the TouchBar Dock Widget. I currently do something similar with custom BTT buttons and "Show / Hide Specific Application".

If the dock widget had this feature, I could get rid of a lot of buttons on my touchbar.

Here you go.
Hide Application.json (2.4 KB)
It's basically the dock widget that will bring the selected app to the front for 0.4 seconds and then hide it running an apple script (for the improbable case in which you have an app that can't be hidden by ⌘H).

Not really what I am looking for. I literally want to hide the application when I press the button (only if the application is active). This is because, if I'm bothered to use the touchbar, my fingers are already around the touchbar and it would take longer to press CMD+H

BTT has something like this with "Show / Hide Specific Application"

Hm, maybe I don't get it right so. What I posted hides the opened windows of the app and shows you again what you were doing when triggering the touchbar action.
Or do you mean that you want to hide it from the touchbar?

Sorry, I didn't explain myself properly:

Currently, clicking on an app on the Touchbar Dock Widget will put it up on focus and open it. If you click on the same app again, it will not do anything (because the app is already opened and on focus).

What I thought about is: once the user clicks on an icon on the Dock Widget:

  • If the app is not on focus, open it (this is already done by BTT)
  • If the app is already open, and on focus, hide it (CMD+H)

At the moment, you can achieve something like this by creating a button for each application you need and using the rule "Show / Hide Specific Application".

Ah, only if the app is frontmost. Maybe there's a solution with Apple script I'll look into it.