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

@JMichaelTX You are right, it is unpredictable. I've completed all the macros and added the regex to the group that was suggested by @gglick. But all of a sudden, when I type "s" even in the compose window it triggers the Flag (⇧⌘L) star/flag macro due to what I setup. Therefore, I'm giving up on these set of macros.

And to answer your question, you assume that J is lowercase unless it has a shift (⇧) next to it. At least that's what I did.

I actually got pretty far, but as I began using them things as you said, became unpredictable.

08%20PM

FWIW, my approach to problems like this is to use a modifier key with the main key I want to use. For example, I use OPT-J and OPT-K to trigger macros for UP and DOWN arrows. Most of the time I don't need the character that would normally be output by the OPTION key+.

I feel like it's a bit too soon to give up on these, especially since I can confirm this macro works perfectly for me, toggling the flag in the main Mail window and typing "s" in the composer:

Star.kmmacros (2.3 KB)

I would suggest importing that macro (which includes its macro group settings) and seeing if that does the trick for you as well. But even if it doesn't, there's another way you could make this group of macros work; by activating and deactivating them manually:

This way, you'll know that these macros are only in effect as long whenever the palette is visible, and when the palette is gone, you'll know the keyboard will function as normal. It's effectively a way to modalize groups of macros, and one I've found particularly useful for ones that use single keys as their triggers.

Here is another one that isn't working "Send Mail" ⌘Return isn't working for ⇧⌘D.

This works fine for me using the menu selection action:

But a macro like this that's meant to be used in the composer window can't be put in the same macro group that's meant to only be used in the mailbox window. This one needs to be in a typical Mail-specific macro group that's available in all windows:

53%20PM

The way I've been accomplishing this in other applications (haven't tried in Mail.app) is by checking whether the Show Substitutions command is enabled or not. If it's enabled (regardless of whether it's checked or not) then I'm editing text. If it's not enabled, then I can safely assume that single keys without modifiers are safe to use for triggers.

In this example, I want the Escape key to just type Escape when editing text, and to do something else when not editing text.

Hope this helps.

1 Like

Unfortunately it seems to be inconsistent. "Show Substitutions" is still enabled in Brave Browser even when not in an editing area:

image

1 Like

Any chance someone could share more of their kmmacros files from this thread? In particular, the j and k to go to next/prev messages would be great.

I'm new to Keyboard Maestro and this is the first thing I'm trying to do with it. The Star.kmmacros file above worked well for me, and I could use that template for an Archive action. But I'm at a loss finding information on how to go to next/prev messages in Mail. (Searching around did not help—the Applescript examples around the web for this type of thing are all super old and didn't work.)

I created some but they never worked well so I got rid of my Apple Mail to Gmail macros. Triggers without modifier keys don't work well. Also, welcome to this awesome Keyboard Maestro community!

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!