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.
  • 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.
Case sensitive keys (overrides any gmail shortcuts using that key).
'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:
  1. close gmail window/tab
  2. Clear cache (ctrl-shift-delete)
  3. 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 keypresses
20080214.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 Feed-icon

1 point
login to vote
Erke user
Posted Oct 2, 2008

Yes I can open the main help screen and navigate through the menus but the keys I assign do not seem to work. =(

1 point
login to vote
sewpafly script's author
Posted Oct 2, 2008

@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?

1 point
login to vote
Erke user
Posted Oct 2, 2008

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

2 points
login to vote
sewpafly script's author
Posted Oct 1, 2008

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"

1 point
login to vote
sewpafly script's author
Posted Aug 16, 2008

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.

1 point
login to vote
Posted Aug 15, 2008

I replied to that discussion but it seems to be moderated and my messages haven't gone through yet

1 point
login to vote
sewpafly script's author
Posted Aug 15, 2008

Santiago, I opened a discussion at Gmail Power Users Group. We can talk there or email.

1 point
login to vote
Posted Aug 15, 2008

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)

1 point
login to vote
Posted Aug 15, 2008

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").

1 point
login to vote
sewpafly script's author
Posted Aug 7, 2008

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?)

1 point
login to vote
Posted Aug 7, 2008

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.

1 point
login to vote
bantab user
Posted Jul 28, 2008

Posted problem update on power-users group.

1 point
login to vote
bantab user
Posted Jul 25, 2008

Seems to be working again. I'll update if there are any further problems.

1 point
login to vote
bantab user
Posted Jul 25, 2008

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!

1 point
login to vote
sewpafly script's author
Posted Jul 24, 2008

I have a fix and will upload soon.

1 point
login to vote
sewpafly script's author
Posted Jul 24, 2008

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.

1 point
login to vote
cwpollock user
Posted Jul 24, 2008

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?

1 point
login to vote
sewpafly script's author
Posted Jul 14, 2008

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.

1 point
login to vote
Posted Jul 14, 2008

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

1 point
login to vote
viz user
Posted Jun 29, 2008

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...

1 point
login to vote
viz user
Posted Jun 24, 2008

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.

1 point
login to vote
johnny16 user
Posted Jun 21, 2008

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.

1 point
login to vote
sewpafly script's author
Posted Jun 20, 2008

Try clearing your cache and reloading gmail.

1 point
login to vote
johnny16 user
Posted Jun 19, 2008

The new Firefox 3 seems to break the Gmail Macros again. Anyone has the same problem?

1 point
login to vote
sewpafly script's author
Posted May 12, 2008

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.

You could comment on this script if you were logged in.