Best way to hide all apps?

I need a macro to Hide All Apps. Apparently, there is no "pause until all apps are hidden" action, so, is this the best way to do it?

(I'm not super satisfied with this.)

Hide All Apps.kmmacros (1.8 KB)

Hi, @ikenassi. How about this?

Download: Hide All Applications.kmmacros (5.9 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.4.1 (22F770820d)
  • Keyboard Maestro v10.2

1 Like

Thanks. I like it. I hadn't thought of that approach.
I'm testing it now. If no problems, I'll adopt it.

Here’s an alternative using only AppleScript. I’ve been using it for a couple of years now without any issues.

------------------------------------------------------------
# Author   : Chris Thomerson (@cdthomer)
#
# Version  : 1.1.0 (changed delay to variable and removed superfluous lines)
# History  : 1.0.0 (Initial script)
#
# Created  : Friday, September 3, 2021
# Modified : Wednesday, August 9, 2023
# macOS    : 11.6.3 (Big Sur) - 13.5 (Ventura)
# Tags     : macOS, Finder, Applications
#
# PURPOSE
# Hide all applications, including any Finder windows
#
# DISCLAIMER
# Permission to use, copy, modify, and/or distribute this
# software for any purpose with or without fee is hereby
# granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
# USE OR PERFORMANCE OF THIS SOFTWARE.
------------------------------------------------------------
set delayLength to "0.0" -- ← adjust this number to whatever works best for your system
tell application "Finder"
	activate
end tell
tell application "System Events"
	delay delayLength
	key code 4 using {command down, option down}
	delay delayLength
	key code 46 using {command down}
	delay delayLength
end tell

Thanks. I wasn't aware of those shortcuts.

Cdthomer and _jims:

I wound up using a combination of _jims’s suggestion, and my home grown “close all finder windows”. I didn’t mind minimizing apps, but for my application I wanted to close the finder windows, not minimize them. I’ll post my solution soon.

1 Like

There's this too in case you haven't seen it:

https://wiki.keyboardmaestro.com/action/Hide_All_Applications

1 Like

thanks, but knew about that one. Finder is special however.

Here's what I wound up doing. It uses the Finder to hide others, and it uses the Finder to hide its own windows. Thanks to all for the help.

Desktop Images Macros.kmmacros (10.9 KB)

3 Likes

@ikenassi, I really like the option to close the Finder windows but more often I'll want to minimize them. Here's a macro with both...

Download: Hide All Applications & Minimize or Close All Finder Windows.kmmacros (8.1 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.4.1 (22F770820d)
  • Keyboard Maestro v10.2

I already have a macro similar to these for hide all. But reading this, learned something new. I was not aware of the %TriggerValue% token. I'm sure I have duplicate macros with separate to do similar things triggered by keystrokes with and without the option key. Now I can combine them. I'm sure this will be useful in the future. Glad I read your solution.

2 Likes