MACRO: "Select All" Messages in Gmail without Moving the Mouse

I use this macro in conjunction with Gmail's default shortcuts (must be activated, see here: https://support.google.com/mail/answer/6594) to quickly select all messages in the inbox view and archive them.

Make sure to change the "title contains" to your own email address, and GET the location of your checkbox in gmail's web interface, which will be different from my own based on your resolution and window placement. I use it for Chrome, but you can use it with any browser by changing that option in "The front window of." Place it in a restricted folder for that browser to keep it from activating when you're not expecting it :slight_smile:

Gmail Select All.kmmacros (4.4 KB)

Sorry I am a KM newbie and I was wondering why you use a “mousing action” instead of just simulating a key press of “e” to archive the selected messages?

Thanks

I do still archive with "e," this ⌥a hotkey simply presses the Select All checkbox for me without having to mouse there myself.

You would probably be better off injecting javascript instead.

document.getElementById(':3a').children[0].children[0].click()

If you were to use javascript injection you also wouldn’t need to enable keyboard shortcuts to archive them:

var down = new MouseEvent('mousedown');
var up = new MouseEvent('mouseup');
var elem = document.getElementsByClassName('T-I J-J5-Ji lR T-I-ax7 T-I-Js-IF ar7')[0]
elem.dispatchEvent(down);
elem.dispatchEvent(up);

And there are likely even better ways to do both of these using GMail javascript api

1 Like