Multiple Gmail Accounts

with AutoHotkey

by Philippe Lamarre
last updated August 10, 2018
difficulty.png intermediate

by Philippe Lamarre

Description 

If you are a Gmail user with multiple Gmail accounts, it can be a tedious process switching from one account to another. But what if you could get from one account to another in less than 5 seconds without disrupting your workflow? The following script is designed to do just that.

Warning: As a result of unpredictable changes in the way that logging into Gmail works, this AutoHotkey script may require modifications.

Steps

1

overlay-um-date.gifPrepare your overlay
Choose two unassigned keys on the Enterpad where you will assign two Gmail accounts. Name them something appropriate, like "Gmail Work" and "Gmail Personal".

2

Code installation

Copy and paste the following script in the AutoHotkey script template file ( Enterpad.ahk ) at the location of the key numbers where the two Gmail account shortcuts will be set.

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

3

Customization

The code now needs to be customized for each account. Where you see "choose-account-0", replace 0 by 1 for the second Gmail account. Where you see "Type your password here", type the account password.

More Info

The script will open Gmail in Internet Explorer, even if it is not your default browser.