I've been trying to create a series of macros to be able to use Gmail shortcuts with Apple mail using the help of Keyboard Maestro. After I've completed about 75% of the shortcuts, it occurred to me that when typing the text of an email certain letters will conflict with the macro triggers.
For example, I have set the letters J and K as triggers to move to the next or previous message. This, of course, conflicts when you are just typing an email that has words that contain the letters K or J in them. Does anybody know of a solution where regular typing doesn't conflict with the macro triggers (I.e. navigation)?
Is there a way to make the triggers not active with a specific window is in front (i.e. the compose window)?
Assuming the title of every mailbox view in the main Mail window ends with something in parenthesis, this should prevent the macros from being triggered when in any other window, like the message composer.
That's very clever, @gglick, and may be as close as you can get.
The only pitfall I see is if the Subject in the Compose window ends with a ")", like this: Test with (Parenthesis)
Yes, it's definitely not foolproof, but given how infrequent ending parenthetical statements are in email subjects and how common they are in the main Mail window, I figured it would indeed be as close as you can get.
@peternlewis has stated numerous times that a macro that types the same keystroke that is used to trigger it can lead to unpredictable behavior. For example, it might just re-trigger the macro. Or, it might not. Unpredictable.
Also, how do you know whether to type a lower or upper case "J"?
@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.
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:
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.
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:
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.
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!