Make Gmail delete the current message and open the next one

by fred on March 12, 2009 · 2 comments

in Code

Gmail is great and their keyboard shortcuts help out quite a bit, but it was missing the ability to delete the current message and move to the next message in any folder or list of messages. After discovering AutoHotKey (AHK) to build and customize shortcuts for applications, I decided to solve this problem I’ve been dealing with for some time.

I did find some pages online where people were asking how to make this work or why Gmail doesn’t offer this feature. So I looked at the Keyboard Shortcuts in the Gmail Lab for a solution, but you can only do one command at a time there. So the key sequence is #o (pound sign and then the letter “o”) to move the current message to the trash and then open the next message.

Sidenote: Even if I wanted to use the delete key and then the letter “o”, I couldn’t put in \127 for the ascii code for Delete in the Keyboard Shortcuts Lab feature. It seems that the textbox only allows 3 characters.

So I cooked up this solution to make the delete key do it all – #o.

First, you need AutoHotKey installed. Then you need to create a new AutoHotKey file or just edit the AutoHotkey.ahk that gets installed by default. You can have multiple AHK files loaded at the same time if you want. I just keep using the same one for all my shortcuts.

Edit the AHK file with notepad or your favorite text editor and copy/paste the following lines. I prefer to use Notepad++ but it really doesn’t matter.

SetTitleMatchMode 1
#IfWinActive Gmail -
Delete::
; Delete the current message and
Send #
;read the next message
Send o
return
#IfWinActive

Double-click on your newly edited and saved AHK file. This will load it and you will see AHK running in the system tray as a green square with an “H”.

image

Now open Gmail and go to your inbox or spam folder where you have messages you want to delete. Then click on the first one to read it and hit the delete key.

In order for this to work after you reboot your computer, you need to add a shortcut to this AHK file to your startup folder so it loads automatically after a reboot.

 

There are a couple of things that could go wrong where this solution will not work:

  • If you changed the Keyboard Shortcut in Gmail for Open conversation from a “o” to something else or you changed the Move to trash from “#” to something else, you need to change the AHK file to match. Look at the lines that start with Send in the AHK file and change the characters as needed, save the file, right-click on image in the system tray so you can click on Reload This Script. Then see if the delete key works like you want it to.
  • If you enable the Title Tweaks in Gmail Lab to show the folder name followed by “- Gmail” in the title of the browser, you will need to change line 2 in the AHK file to
#IfWinActive - Gmail

 

Here are some notes about the AHK commands used here:

  • Since AHK can map keys in any application I needed to specify the title or window name of the application and SetTitleMatchMode 1 describes how AHK will look for the title. From the AutoHotKey documentation: A window’s title must start with the specified WinTitle to be a match
  • To make AHK only take over keys in a particular application, use IfWinActive see the AutoHotKey documentation for more details.

Related posts:

  1. Anthem.net fix for GetAnthemManagerKey Change GetAnthemManagerKey in Manager.cs to the following to fix the problem with the page handler changing during ajax callback.  ...
  2. How to Dynamically Create Images Ask any ASP developer who has ever tried to dynamically create his own images and he’ll tell you it’s a...
  3. The Secrets to Uploading Files with Ease In the golden, olden days of ASP, managing a file upload was pretty difficult. Most developers reverted to digging deep...
  4. Using the Sharing Caulk Extension There is a cool extension inside of Graffiti Extras called Sharing written by Thomas Freudenberg. It displays a list of...
  5. Using MSBuild to deploy website files After reading several blogs and searching the net for examples, I finally finished our team build script. Some things to...

{ 2 comments }

ricky May 12, 2009 at 6:12 pm

great info, thank you..

Sulumits Retsambew June 22, 2009 at 3:42 pm

hello, this is my first time i visit here. I found so many interesting in your blog especially on how to determine the topic. keep up the good work.

Comments on this entry are closed.

Previous post:

Next post: