Build my own Gmail keyboard shortcuts in Mail.app?

Hey all,

I'm trying to construct my own set of keyboard shortcuts for Mail.app. I want navigation shortcuts as though I were in Gmail but of course I need to be able to compose email normally. So here's an example of a solution I have for an "Archive" instruction:

image

This works great, but there are other things that I'm not sure how to do. For example, going down the list in my inbox:

image

This, of course, will not work during message composition. It will move my cursor down whenever I try to type a J. I considered making the trigger conditional on the name of the window, but the message composition window seemingly has no name in the title bar, and the main Mail.app window changes its name based on which mailbox you're currently viewing.

Anyone have any suggestions on how I might proceed?

tl;dr: How do I achieve custom navigation instructions in the main Mail.app window while maintaining regular typing in the message composition window?

I was able to resolve my own problem, though I can't say it's elegant. Basically, I'm checking the color of a particular pixel to see if I'm in a message composition window or not. Here's the workflow:

image

Essentially, I'm checking to see if there's a little envelope button on the upper left hand corner of the window. If there is, then we are in the main viewing window.

image

If there isn't, then we're in the message composition window:

image

If anyone knows of a more elegant solution though, I'm all ears.