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:
- If the "Rebuild" menu is enabled, ⌘+W will hide the app.
- 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.