Activate and Hide Apps by the Same Keyboard Shortcut

Hello,

I set a simple action to activate 2 apps by pressing an example keyboard shortcut. Something like this:

Is there any way I can set this action to hide these two apps by pressing this shortcut again? And when I press it again they'll be active etc

Cheers,
Michal

Hey Michal,

You might start out by trying an If Then Else action that looks to see if either app is frontmost and hides them if so – or activates them if not.

If that doesn't do the job then there are other methods.

-Chris

What I did wrong here? App is showing but not hiding

Yep, easy enough. Just use the IF/THEN like Chris @ccstone suggested.

You said "Toggle", so that is exactly what this Macro does.
It is just an example using BBEdit -- you need to adapt to your specific needs.
Put all you your apps to be toggled in BOTH sections of the IF/THEN.

But the Macro Group this is in should probably be a Global group, with no specific apps named.

MACRO:   Toggle Activate/Hide Apps [Example]


#### DOWNLOAD:
<a class="attachment" href="/uploads/default/original/3X/0/e/0e2897bafd4ac5c24ab1c39e23004f7303cf5a94.kmmacros">Toggle Activate-Hide Apps [Example].kmmacros</a> (3.8 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**

---



![image|536x861](upload://lV0YlZ0WMknG5xijMRKqHafEUo2.png)
1 Like

Sorry I don't understand at all what you just said. I'm unexperienced when it comes to variables etc and don't know what "DND_TAH_AppStatus" is. I did some basic macros in the past but I simply don.t get it - sorry;)

Perhaps I should just pay someone to do an exact macro for me. Take 2 default mac apps and do exactly as I said in first post please. Then PM me with your paypal ID and price

Hi @meeffe, here's an option with "if then else":

2019_05_16_Support_1

Since I have not installed your apps, you would have to add them to your site and then your desired window action.

Apps toggle.kmmacros (7,7 KB)
Apps%20toggle

1 Like

In your original script , change this:

To this:
24%20am

2 Likes

The macro of @JMichaelTX does the same thing as "if then else" @meeffe. In the gif you see the same behavior.
But I added another Move a Window action to the Hide action. This will return the two apps to their original center view, if you use one of the apps alone in another view.

You have all possibilities :wink:

2019_05_16_Support_2

Toggle Front:Hide Apps [Example].kmmacros (9,0 KB)

24%20PM

1 Like

Many thanks for sharing the macro @JMichaelTX :+1: I didn't know such a possibility until now.

This did the trick appleianer. Thanks a ton:grinning:
PM your paypal ID if you want to;)

1 Like

I thank you @meeffe, thanks to your question I also learned something new.
The @JMichaelTX solution was also new to me.

"DND_TAH_AppStatus" is a KM Variable. See that link for a good overview with examples of how to use.

The name of the KM variable follows my naming convention, which gives me a lot of info in a quick glance:

  • The "DND" stands for "Do Not Delete", which means that you should NOT delete this variable in the KM Preferences Variables tab, or elsewhere. It is needed by the current macro, and maybe by other macros.
  • "TAH" stands for "Toggle Activate Hide", which is in the name of the macro. This helps give the KM Variable a unique ID associated with a specific Macro.
  • "AppStatus" is, of course, just a description name for the Variable, indicating its contents.
  • The "__" double underscore prior to the "AppStatus" means than if you were to use this in a Prompt for User Input, only the "AppStatus" would show, making it easier to read.

If you have not done so yet, I recommend going through this checklist:

Getting Started with Keyboard Maestro

  • Read the Quick Start.
    • This is essential to become familiar with KM terminology
  • Do the tutorial (Help ➤ Tutorial) in the KM Editor.
    • Gives you a live walkthrough of creating a macro in the KM Editor
  • Review/Browse the Available Macro Actions
  • For Help with an Action in your Macro, click on the gear icon at the top right of the Action, and select "Help"
  • Search the Keyboard Maestro Wiki for detailed help.
  • Start small, and grow your macros organically.
  • Be prepared for some trial and error in the beginning.
  • Make good use of this Keyboard Maestro Forum
2 Likes

Oh, thank you for such helpful tips! I'm definitely going to take that systematic approach haha.