Modified Gmail Macros v. 2.0
Last update on Jul 25, 2008
Extra (customizable) keyboard shortcuts and macros for Gmail 2.0. Based on the work of Mihai @ persistent.info.
For comments/questions/requests for help.
20080127.1: Fixed for recent gmail changes (go to, label). Removed dependencies from Folders4Gmail (if you have labels with '/' or '\' in them they are accessed by what comes after the '/' or '\'. Might cause problems from labels with identical sub-structure. I'd be interested to know if anyone is actually impacted by this. Bug with new labels running macros fixed. Fixed bug caused by recent greasemonkey security update.
20080124.1: Bug with help display, bug with g+"Starred".
20080114.1: Added help keyboard shortcuts (up/down to move between sections and right arrow to start modifying macros -- then tab as normal). A bit clunky, but it works.
20071206.1: Added Folders4Gmail support, auto-update code and some minor bug fixes.
- See 'h' for list of macros available.
- If your configured keys ever get hosed, you can always go to about:config and reset the "macros" and "selectors" greasemonkey values. I don't think that this should be a problem, it's pretty stable.
- Use keys to navigate the help screen: up/down to change sections, right enters macro section. Use tab to get to next macro, etc.
'g' --> 'go to label/quick link'
'l' --> 'apply label'
'L' --> 'remove label'
'N' --> 'create and apply label'
'E' --> 'Mark as read and archive'
'f' --> 'focus: loads all inbox/unread/starred messages
in the current label or search'
'i' --> 'move selected messages to inbox'
'T' --> 'Mark as read and move to trash'
'O' --> 'Open all conversations in the current thread
',' --> 'Mark as read, all unread'
'q' --> 'Add quick link'
---
't' --> 'Trash'
'r' --> 'Mark as read'
'R' --> 'Mark as unread'
'e' --> 'archive'
'X' --> 'Select'
'a' --> 'all'
'n' --> 'none'
'r' --> 'read'
'u' --> 'unread'
's' --> 'starred'
't' --> 'unstarred'
Troubleshooting
Gmail & greasemonkey (or firefox extensions) have an interesting relationship. If you reload gmail you'll probably have problems unless you clear your cache first. If you seem to be having problems:- close gmail window/tab
- Clear cache (ctrl-shift-delete)
- Reload gmail
Tips & Tricks
- 'Z' enables debugging: output is to the console (Tools-> Error Console)
- The ignore option can be used to shift into gmail mode. Add an ignore shortcut then after pressing this key, whatever you press will pass through to gmail. Be careful, the ignore key is not trapped (meaning that you can ignore the next key after performing a macro, or if the ignore key is a gmail shortcut, gmail will do something.
Version History
20080724.1:* Modified isQuickLink * No longer traps keyboard commands on <input /> elements.20080714.1:
* Shortened Labels now show full path information. * Reworked the update code.20080617.1:
* Gmail labs keyboard shortcuts disappear :(20080611.1:
* Updated for Gmail Labs integration. Deprecated features that can be changed through gmail's keyboard shortcuts. * Support for quick links: 'g' will goto a quick link and 'q' adds quick link.20080603.1:
* Fix for RTM * Fix for GTDInbox and other label issues * Fixed some keys not trapping keypresses20080214.1: New labels fix was weak and needed to be redone.
20080127.1: Fixed for recent gmail changes (go to, label). Removed dependencies from Folders4Gmail (if you have labels with '/' or '\' in them they are accessed by what comes after the '/' or '\'. Might cause problems from labels with identical sub-structure. I'd be interested to know if anyone is actually impacted by this. Bug with new labels running macros fixed. Fixed bug caused by recent greasemonkey security update.
20080124.1: Bug with help display, bug with g+"Starred".
20080114.1: Added help keyboard shortcuts (up/down to move between sections and right arrow to start modifying macros -- then tab as normal). A bit clunky, but it works.
20071206.1: Added Folders4Gmail support, auto-update code and some minor bug fixes.
You could comment on this script if you were logged in.
80 comments
You could comment on this script if you were logged in.

login to vote
Yes I can open the main help screen and navigate through the menus but the keys I assign do not seem to work. =(
login to vote
@Erke - interesting. you can pull up the help screen after you deleted the keys, but the other functions don't appear to work? If you can't pull up the help screen, try disabling better gmail and any greasemonkey scripts you are using and then just enable this one. Clear your cache and then load gmail. try using 'j' and 'k' to see if you can move the message selector around and if that's working then try typing 'h' to pull up the help screen.
If you can pull up the help screen but the other commands don't appear to work, try typing 'Z' and then open the firefox javascript console (shift-ctrl-j) and clear that, then go back to the gmail tab and try running a couple commands. What's the output to the javascript console?
login to vote
Thank you so much sewpafly! That did the trick and I re-assigned the keys...
Although, the macros doesn't work, no matter what I assign =(
I double checked for collisions and cleared my cache a couple of times but no luck...
Any ideas?
Anyways, thank you so much again for your kind reply.
Sincerely,
Erke
login to vote
open about:config and delete the keys for "greasemonkey.scriptvals.http://groups-beta.google.com/group/gmail-power... Gmail Macros v. 2.0.macros"
and "greasemonkey.scriptvals.http://groups-beta.google.com/group/gmail-power... Gmail Macros v. 2.0.selectors"
login to vote
Did you join the group first? Or you can use the group and "reply to author" which should just send an email to me if you want.
login to vote
I replied to that discussion but it seems to be moderated and my messages haven't gone through yet
login to vote
Santiago, I opened a discussion at Gmail Power Users Group. We can talk there or email.
login to vote
Oh, by the way, in Safari I can refresh GMail without clearing the cache or anything and the script continues to work, so I'm guessing that the problem that shows up in FF with greasemonkey is related to the GM_* functions. Just in case you're interested in tracking down that problem (which I find kind of annoying when in linux and using FF)
login to vote
Hi, I'm using Safari and GreaseKit and I was able to make your script work (kind of). All I had to do was replace the addEventListener part at the beggining for this:
window.addEventListener('load', function() { var gmailapi = typeof unsafeWindow != "undefined" && unsafeWindow.gmonkey || (frames.js ? frames.js.gmonkey : null) gmailapi.load('1.0', init) }, true);Also I had to add the following function:
function Iterator(o) { var r = []; for (x in o) { r.push(x); } return r; }There are several issues while using it in safari such as:
- you're unable to save mappings because GM_* functions don't appear to exist in GreaseKit
- transparency doesn't work
- probably many more issues since I just started trying it
I don't really care about transparency and mappings I can fix it by modifying the defaults in the script.
It would be great if you could adapt future versions of the scripts to at least work in this fashion (if you don't want to define the Iterator function for GreaseMonkey you probably could put it inside an "if" checking (typeof unsafeWindow == "undefined").
login to vote
Try closing gmail and deleting your cache (ctrl-shift-delete) and then reloading gmail. Alternately you could try using the latest Better Gmail 2 extension. (Are you using the new gmail or the old version?)
login to vote
I am using Firefox 3 on Windows XP with Gmail. The script does not work - and neither does Mihai's. However, Mihai's works with FF2 on my laptop (also using winXP). Does anyone have a solution? I really desperately want to use this script as it made my life so much easier, and I am even thinking about downgrading this computer to FF2 to make it work again.
login to vote
Posted problem update on power-users group.
login to vote
Seems to be working again. I'll update if there are any further problems.
login to vote
Worked yesterday... nothing today. r doesn't mark as read, l doesn't label. Not sure if this is google, or if it's just that my cache wasn't clear yesterday. I use GTDInbox and rememberthemilk as well, so I have a feeling it has something to do with it. Is there anything I can give you that will help assess the problem? Thanks for the great app!
login to vote
I have a fix and will upload soon.
login to vote
I put in some fixes for remember the milk awhile ago, but the fix depends on remember the milk making their input boxes have an id that starts with 'rtm'. All their objects conform to this convention EXCEPT the input boxes on the task detail page where you need to put in or edit information... You could talk to rtm about fixing this, as that was the fix that they had originally suggested or I could add a check that looked for an input... and then just ignored keystrokes... I'll look into it.
login to vote
I really want to use this script, but am having trouble getting it to work in conjunction with the "Remember the Milk" plugin. Any thoughts?
login to vote
Good call. I had forgotten that this was something I wanted to add anyway. I have a fix and I'll post the update later today.
login to vote
With reference to the 'label' macro - which has become absolutely essential for GMail (since I uploaded 2Gb of historical mail from outlook)...
I have a lot of folders with the same leaf-node name, e.g:
/Projects/Project1/Admin
/Projects/Project2/Admin
/Projects/Project3/Admin
/Projects/Project4/Admin
/Projects/Project5/Admin
so when I press 'l' and type 'Admin' it says there are 5 of them, but it's impossible to know which of the Projects it belongs to... Is it possible to show the full path in some way (when pressing the up and down buttons to select the alternatives) so I can tell which of the projects it belongs to?
It would be a really useful change...
Cheers, M
login to vote
Scripts are working well today. Greasemonkey scripts have worked every time I opened gmail today (as compared to before). Something changed in gmail??? I haven't made any changes...
login to vote
Hi sewpafly. This is an amazing script. Makes the whole gmail/email experience much better.
Lately the working of the script has been flaky. I don't think this is isolated to FF3 (it was even happening with FF2). I don't think this issues is even related to the script. Maybe greasemonkey and gmail. I noticed that when it happens, all my greasemonkey scripts for gmail stop working.
Any ideas on why this might be happening for me. I tried clearing the cache and reloading gmail. It only works once in a while.
login to vote
I've cleared my FF cache and Macros started work again.
Thanks sewpafly for the help and thank you very much for the amazing must have script.
login to vote
Try clearing your cache and reloading gmail.
login to vote
The new Firefox 3 seems to break the Gmail Macros again. Anyone has the same problem?
login to vote
Using latest firefox nightlies is still working for me (except for using 'e' or 'E'). It might mean gmail is rolling out some new changes though.