Multiple Gmail Accounts

with AutoHotkey

by Denis Lamarre
last updated February 16, 2024
difficulty.png intermediate

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.

Attention: This AutoHotkey script is kept for reference purposes only. It is based on the web browser Internet Explorer, which is no longer supported or updated by Microsoft.

Steps

1

overlay-um-date.gifPrepare your overlay
Choose two unassigned keys on the Enterpad where you will assign your 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 (Enterpad.ahk) at the location of the keys you wish to assign.

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. At line #9, where you see "choose-account-0", replace 0 by 1 for the second Gmail account. At line #13, 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.