How Can I Use Standard Gmail Shortcuts in Apple Mail with Keyboard Maestro?

Thanks! I've been having pretty good luck so far with the most basic (y=archive, s=star, #=trash, gi=go to inbox) with a mixture of Menu Items and Applescript, relying on the "a focused window title does not match ([^)]+)$ filter.

But I'm still struggling getting Applescript to select the next message in the list (for j/k support). Seems like this should be fairly easy (and probably is!) but I'm not having luck finding that magical combination of Applescript commands.

Have you seen this resource:

Keyboard shortcuts for Gmail

Those are the keyboard commands I'm trying to replicate while using Apple Mail.

Tbh using the gmail web interface + keyboard is my preferred way to use email, it's amazing. I just want to be able to move away from using Google services.

The title of this topic mislead me -- it only referred to Gmail Shortcuts.
I've fixed the title to include "Apple Mail"

1 Like

These suggestions work well. Has anyone solved the problem of interference with the help and search functions?

Is there a way to say "when not entering text" or "when not in a text field"?

There may be better ways of doing it, but I generally assume that if the 'cut' menu item (under 'Edit') is active, then the user is either entering text or could be entering text.

This one using @JMichaelTX 's "Show Substitutions" trick is working pretty well for me.

  • Group scoped to Mail application
  • Macros [do thing] if Show Substitutions isn't around
  • If it is around, it passes the hot key through

Works for finding. Doesn't universally work for help, but if you open a compose window it will (and I barely use help so it's not really an inconvenience). If someone wants to go bananas for help, perhaps pixel-checking would work.

Any improvements suggested?

Mail.App Gmail Hotkeys.kmmacros (25.6 KB)

1 Like

What about for searching? I often will search in mail for an archived message.

As tested and stated, "works for finding". OPT-CMD-F brings it up as expected for me, and it works as expected for me.

I found an even faster way to do this. Whenever a text field is selected Mail will enable Edit/Complete, and when a text field isn't selected Mail will disable Edit/Complete.

So I use a If Then Else Macro like this for a Mail macro folder.


It would be even better if you could select a Menu condition on a whole Macro Folder.

But I think this is the most reliable.

3 Likes

Thanks @pond - is working well for me. I was having problems when searching the inbox with it not passing through letters from these shortcuts, but with this addition both the gmail shortcuts and search working fine!

This is working well for me, too, but I run into problems when I trigger Alfred while Mail is (otherwise) the frontmost application and I'm not in a text-entry field in Mail. In that scenario, I'm unable to use in Alfred any of the keystrokes that I've assigned to Gmail-style Macros in Mail. Has anyone else encountered the same problem and managed to identify a workaround?

Hey Ben,

Don't use Alfred in Mail...

You can test for the presence of Alfred's input window with AppleScript UI-Scripting.

tell application "System Events"
   tell application process "Alfred"
      return count of (get windows)
   end tell
end tell

Highjacking normal characters for hotkeys is frequently asking for trouble. There are sometimes workarounds that function for the most part, but you almost always end up with clunky typing slowdowns and/or other problems.

You're generally better off adding Control, Option (or other modifiers) to your hotkeys. You still have the mnemonic keystroke but with an added modifier, and this does not interfere with normal typing.

-Chris

1 Like

Thanks, Chris. The warnings are well-taken, and I suspect I'll eventually abandon this approach. For now, though, your solution is -- as promised -- working "for the most part." Using the macro below (adjusted appropriately for each letter), I'm able to use the GMail keyboard shortcuts in Mail, while still being able to type them if there's an Alfred window open and Mail is the active application. There's a very slight delay when I type them in Alfred, enough that trying to type "Keyboard Maestro" might result in "eyKboard Maestro." But there doesn't appear to be a similar delay when I'm typing in a Mail message (presumably because the first "if" condition isn't met, and therefore Keyboard Maestro doesn't need to run the script), and it's a certainly better than anything I would have come up with. I appreciate the assistance very much!

1 Like

Discovered this thread while trying to accomplish the same thing in Mail in MacOS Ventura.

Is anyone successfully using KM for this, and if so, what macro are you using?

I've tried the suggestions above, and none of them work reliably (for me).

I couldn't get this to work consistently so I stopped trying.

For what it’s worth I’ve started to learn the standard Apple mail shortcuts (sheesh they’re complex) because most of them are identical on iPadOS so it becomes more widely useful to me.