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.

Note: AutoHotkey has no limits when it comes to automation in Windows, but for many users who may only need simple keyboard shortcuts, installing and learning AutoHotkey, and keeping up to date, can be overkill. ShortKeeper can be used (with and without an Enterpad) to manage an AutoHotkey-based system in a way most non-programmers will find remarkably user-friendly and and effective [learn more].

Here is how the script with this URL looks like.

Steps

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.