CMD + W to hide Mail.app Macro (v9.2)

By : Martin Zhang
Created : 01/28/2021, 10:24 PM ET
Modified :
Version : 1.0
This macro does:
If the main window of Mail.app is at the front, click ⌘+W will hide Mail.app.
If other windows of Mail.app are at the front, click ⌘+W will close the window.

Purpose:
This macro is intended to solve a problem that the native Mail.app has had for years: When a Gmail account is added, Mail.app pops up randomly.

Comment:
A solution to the aforementioned problem is to make Gmail a normal IMAP account.

Other workarounds are: (1) minimize, or (2) hide the Mail.app window. These require a new set of keyboard shortcuts. But what if I still want to use ⌘+W to close the Mail.app (due to muscle memory)?

This macro is inspired by noticing that when Mail.app main window is at the front, the "Mailbox → Rebuild" menu is enabled. When an individual email is opened in a new window, or when we are writing/replying to an email, the "Rebuild" menu is disabled.

The macro does the following:

  1. If the "Rebuild" menu is enabled, ⌘+W will hide the app.
  2. If the "Rebuild" menu is disabled, it means we are either writing or reading an email in a new window, ⌘+W will function normally, i.e., close that window (not hide).

NOTE: This macro is intended to be put in a macro group that is only enabled for "Mail.app".

CMD + W to hide Mail.app.kmmacros (9.1 KB)

Note: I have an updated macro with a minor change. It does the same thing, but more intuitive and looks nicer.

1 Like

for hiding, there's Hide Front Application

Thanks, @hello.
That looks nicer. I'v updated it.

Modified : 02/03/2021, 5:28 PM ET
Version : 1.1
V1.1 Note: changed ⌘H to "Hide Front Application".

CMD + W to hide Mail.app.kmmacros (9.1 KB)

1 Like