Skip to content

Instantly share code, notes, and snippets.

@DaneWeber
Forked from anonymous/AHK-mailto-gmail.ahk
Last active September 13, 2015 00:39
Embed
What would you like to do?
AHK script to be Windows default mailto app, forwarding to Gmail
; Copied from http://www.autohotkey.com/board/topic/39551-change-the-default-mailto-to-gmail/
; #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
; SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Haystack = %1%
;~ If no paramter is given when the run of it, it registers itself as the default mailto
; commented out because I'd rather set it as default by myself.
; StringLen, pos, 1
; if (pos = 0) {
; RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\Classes\mailto\shell\open\command,, "%A_ScriptFullPath%" `%1
; ExitApp
; }
; Use Regex to match the parts of the mailto: link
MailToMatch := RegExMatch(Haystack, "mailto:([^?]+)", MailTo)
SubjectMatch := RegExMatch(Haystack, "[&?]subject=([^&]+)", Subject)
CCMatch := RegExMatch(Haystack, "[&?]cc=([^&]+)", CC)
BCCMatch := RegExMatch(Haystack, "[&?]bcc=([^&]+)", BCC)
BodyMatch := RegExMatch(Haystack, "[&?]body=([^&]+)", Body)
;~ MsgBox, http://mail.google.com/mail/?view=cm&fs=1&tf=1&su=%Subject1%&to=%MailTo1%&body=%Body1%&cc=%CC1%&bcc=%BCC1%&fs=1
;~ "Sends the mail" with Google to the default browser
Run, http://mail.google.com/mail/?view=cm&fs=1&tf=1&su=%Subject1%&to=%MailTo1%&body=%Body1%&cc=%CC1%&bcc=%BCC1%&fs=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment