I've made a modification so that the script only checks each Chrome tab once. It assumes that if it hits the same tab name again, it has completed a loop. This prevents the sea-sickness noted earlier. Of course, if you have two tabs of the same name before you hit the Gmail tab, it will open a new Gmail tab.
I have also explicitly set SetTitleMatchMode to 2 as on my system it wasn't picking up the "- Google Chrome" at the end of the window title.
;
; Gmail
;
#a:: WinActivate( "Gmail", "http://mail.google.com/mail/" )
#SingleInstance force
SetTitleMatchMode, 2
WinActivate( TheWindowTitle, TheProgramTitle )
{
SetTitleMatchMode, 2
IfWinExist, - Google Chrome
{
WinActivate ; use the window found above
;Click in the address bar
MouseClick, left, 196, 59
WinGetTitle, Title, A ;get active window title
OrigTitle := Title
Loop
{
if(InStr(Title, "Gmail")>0)
{
;Found
break ; Terminate the loop
}
Send ^{Tab}
Sleep, 50
WinGetTitle, Title, A ;get active window title
if(Title = OrigTitle )
{
;Match to original title, assume all seen
break
}
}
}
;Was the tab found?
WinGetTitle, Title, A ;get active window title
if(InStr(Title, "Gmail")>0)
{
;Found
} else {
Run, "https://mail.google.com/mail/?shva=1#"
}
}
return