Multiple Gmail Accounts

with AutoHotkey

by Philippe Lamarre
last updated June 16, 2014
difficulty.png Intermediate

by Philippe Lamarre

Description 

If you are a Gmail user, you might have multiple Gmail accounts. What does this mean ? It means a long process when you want to switch from an account to another.

But what if you could, in less than 5 seconds, go from your professional account to your personal one without disrupting your workflow ?

When you integrate the URL ( https://mail.google.com/mail/?logout&hl=en ) in an Autohotkey script, it becomes easy to flip flop between different adresses.

Here is how the script with this URL looks like.

Steps

Note: You can trigger the following script with your standard keyboard if you don't have an Enterpad. If so, just replace the line 1 on step 2 with your hotkey definition. The Enterpad hotkeys are useful for efficiency driven professionals who want to avoid the trouble of dealing with too many Windows hotkeys [learn more].

1

overlay-um-date.gifPrepare your overlay.
Choose free keys on the Enterpad to use your Gmail accounts.
Name it something relevant. This example uses Gmail Work and Gmail Personal.

 

2

Code installation.

Copy/paste the following script in your AutoHotkey script template ( Enterpad.ahk ) at the chosen key location.

001:
ie := ComObjCreate("InternetExplorer.Application")
 ie.Visible := true

ie.Navigate("https://mail.google.com/mail/?logout&hl=en")
 while ie.readyState != 4 || ie.document.readyState != "complete" || ie.busy
 Sleep, 100

ie.document.getElementById("choose-account-0").click()
 while ie.readyState != 4 || ie.document.readyState != "complete" || ie.busy
 Sleep, 100

ie.document.getElementById("Passwd").value := "Type your password here"
 ie.document.getElementById("signIn").click()

ObjRelease(ie)

Return
 

 

More Info

Take note here that it works with Internet Explorer only. Where you read “choose-account-0″, you have to replace 0 by 1 if you want to set your second account and by 2 to set your third account and so on. Where you read “Type your password here”, you have to put your account password.

If ever your script does not work anymore, make sure you come back here and see if the coding did not change. It can be possible that Google changes an ID and your script will stop working. It's been six months we are using it and nothing has changed and it works perfectly.