Activate and Hide Apps by the Same Keyboard Shortcut


#1

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


#2

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


#3

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


#4

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]

~~~ VER: 1.0    2019-05-13 ~~~

DOWNLOAD:

Toggle Activate-Hide Apps [Example].kmmacros (3.8 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


image


#5

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


#6

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

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


#7

In your original script , change this:

To this:
24%20am


#8

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:

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

24%20PM


#9

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


#10

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


#11

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


#12

"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

#13

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