Gmail has keyboard shortcuts for features I've never even heard of but they don't have one for "Print".
This is what happens when you live in a tech bubble instead of the real world. I'm guessing someone decreed that "We [at Google] don't want to make printing easy because blah blah paperless lifestyle."
I googled around and did not find any way to assign a keyboard shortcut to it.
It's possible one of the JavaScript gurus might find a way to target the print button using JS, but unfortunately I do not know how to do that.
(The print icon is set as 'tabindex=0' which means -- as far as I can tell -- that it is supposed to be the default navigation item when pressing 'tab' but that does not seem to be the case at all. I don't know if there is a way to trigger it by 'tabindex' either… tabindex seems like one of those good ideas that doesn't seem to work as expected, or be well-supported.)
I do have a workaround… but I don't think it's probably one that you want… use Mailplane. Its "Print" function seems to replicate pressing the "Print" icon, and brings up the regular macOS print dialogue window. This should mean that you could control the whole thing via Keyboard Maestro. Depending on how badly you want to do this, it might as least be worth checking out the demo of Mailplane? I've used it for years and consider it to be top-notch, and my favorite way to use Gmail on the Mac.
(Since someone might ask or wonder: Kiwi for Gmail just seems to print the entire browser window, which isn't what anyone wants.)
I played with hitting "shift-tab" twice and that got me to highlight the print icon where I could press print via the enter key, but I was not able to get KM to accomplish the SHIFT-TAB. Would prefer not to use Mailplance since I have some extensions that are not supported.
Do I take this to mean that you are using Google Chrome to read Gmail? Just wondering if maybe someone out there has a Chrome-specific way to solve this.
This is what I came up with, which seems to workbut you must not have selected anything else after opening the message. But if you just navigated there using J or K then this should work:
Note that I tend to use a lot of 'pause' statements when creating something like this. You might be able to get away with shorter ones, but in the "development" stage, I find them helpful.
The last one is definitely necessary, as it takes a few seconds for Chrome to render its fake print dialogue box. Once that is there, you can use ⌥⌘P to bring up the regular print dialogue box. From there you can use the ⌘P to Print as PDF "trick" if you have that enabled. You'd probably still need to intervene to name the PDF and maybe even choose a folder to save it to.
But maybe this will get you started?
Let me know.
p.s. I found this question interesting enough that I also posted it on Ask Different. Maybe someone there will have an idea, too.
So strange, for me, KM will not emulate the shift-Tab. I can do it manually but KM doesn't do anything. I used debug and it recognizes that it is chrome and walks through it. That was really cool of you to post on Stack Exchange, btw. Thanks man.
For some reason Apple keeps the default "Text boxes and lists only" which I find weird. And it may be completely unrelated. It's just the only thing I can think of as to maybe possibly why Keyboard Maestro wouldn't be able to emulate that?
(Now that I think about it, my idea doesn't make much sense, but maybe Peter will have an idea.)
I had KM look for the printer image on my screen and then click it.
FYI, if you read gmail sometimes on an ios device, you can share the message to Print and then pinch zoom in on the preview. At this point you can share the message to an app as a pdf. I use this to send pdfs to DEVONthink, but you could use it to send to Dropbox, Box, etc.
Here is a screenshot of the macro that is the one step. My test was with Vivaldi (Chromium browser) running on macos Mojave. I selected a message in my inbox to view and then triggered the macro with the hot key.
I just noticed 9.03 of Keyboard Maestro is available. I updated and retested with that version. It still works for me in both versions.
I can get it to find the image with the same macro --- I had this one. And it says 1% and highlights in green, but but then it stops and the client doesn't work in either Chrome or Safari. Not your issue, I don't know what the problem is, but I wanted to say thank you.