Skip to content

Instantly share code, notes, and snippets.

@tdalon
Created February 3, 2021 13:16
Show Gist options
  • Save tdalon/a6accc91b6ee197f9104efa9e285e396 to your computer and use it in GitHub Desktop.
Save tdalon/a6accc91b6ee197f9104efa9e285e396 to your computer and use it in GitHub Desktop.
AutoHotkey script to compose a Gmail email in a popped out window.
#SingleInstance force
SetTitleMatchMode, 2
ComposeTitle = Compose Mail -
If WinExist(ComposeTitle . " ahk_exe chrome.exe") {
WinActivate
return
}
; Loop on all Chrome Windows
WinGet, id, List,ahk_exe Chrome.exe
found := False
tabSearch = Gmail
Loop, %id%
{
hWnd := id%A_Index%
WinActivate, ahk_id %hWnd%
; Loop on all Tabs in Chrome Window
WinGetTitle, firstTabTitle, A
title := firstTabTitle
Loop {
if (InStr(title, tabSearch)>0){
found = True
break
}
Send ^{Tab} ; switch to next tab
Sleep, 50
WinGetTitle, title, A ;get active window title
if (title = firstTabTitle){
break
}
} ; end Loop Tabs
if (found)
break
} ; end loop Chrome windows
If !(found) {
Run run C:\Program Files (x86)\Google\Chrome\Application\chrome.exe https://mail.google.com/mail/ca/u/0/#inbox"
WinWait, Inbox ahk_exe Chrome.exe
}
SendInput +c ; Shift+C
;WinWait %ComposeTitle%
;winmove, A,, 1750, 303, 1725, 935; moving the window to my preferred position
return
@tdalon
Copy link
Author

tdalon commented Feb 3, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment