codybear wrote:
sumon wrote:
Do you want me to share?

Sharing is caring.

I actually dislike that saying (no offense), because it implies that one does not care if one does not share (source code). There are sometimes valid reasons for not wanting to share, and just because intellectual property can be copied as opposed to loaned, used or taken, doesn't mean it's less of a property.
Anyway, since the development of this app is halted and I could use all the inspiration I need to (or see someone else develop it - and
share *winks*) I'll post the code in its' current form. Beware, as you need to input username (without the @gmail part) and password for it to work. This one also require Notify() - I also modded it to have a static width, and was originally intended to be scheduled with Appifyer, but Appifyer can't schedule apps yet.
So, in other words, you will mostly want to focus on the CheckGmail label, and how I use it to retrieve data from Gmails RSS stream, and extract relevant information using RegEx.
Anyway, I care (always):
Code:
/*
< MAILY>
Version:
Author: Simon Strålberg [sumon @ Autohotkey forums, simon . stralberg @ gmail . com]
Autohotkey version: AHK_L (Unicode, x32)
Dependencies:
- (?) Notify.ahk by gwarble & more [http://www.autohotkey.com/forum/viewtopic.php?t=48668]
CHANGELOG:
v.
- 0.7 initial release
-
TODO:
- Commandline support in the form of %1% being label (or "Gmail"), %2% number of hits to return
-
LICENSE: If no license documentation exists, [http://www.autohotkey.net/~sumon/license.html]
Script created using Autohotkey [http://www.autohotkey.com]
THANKS TO:
firace for "Extremely fast gmail checker" [http://www.autohotkey.com/forum/viewtopic.php?t=61762]
rippa for helping me with the RegEx
*/
#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.
#SingleInstance, Force
/*****************
** Autoexecute **
******************
*/
if (!FileExist("data\favicon.ico"))
{
FileCreateDir, data
UrlDownloadToFile, http://mail.google.com/favicon.ico, data\favicon.ico
}
/****************
** Subroutines **
*****************
*/
DefineVars:
user := "YOURGMAILACCOUNTNAME", password = "YOURGMAILPASSWORD"
user := (user ? user : user_default), user_default := user ; If you for example wanted to set and retrieve the data from an ini, or whatever
password := (password ? password : password_default), password_default := password
maxcheck := (maxcheck ? maxcheck : 5) ; Max number of emails to display
timeout := (timeout ? timeout : 10)
label := "AHK" ; The label of your inbox to check. Leave blank to check your inbox
CheckGMail:
If (User AND Password)
URLDownloadToFile, https://%user%:%password%@mail.google.com/mail/feed/atom/%label%, gmail.xml
else
URLDownloadToFile, https://mail.google.com/mail/feed/atom/%label%, gmail.xml ; Requires a
FileEncoding, UTF-8
FileRead, gmailXML, gmail.xml
RegExMatch(gmailXML, "<fullcount>(.*)</fullcount>", FullCount), FullCount := FullCount1
RegExMatch(gmailXML, "<title>(.*?)</title>", PageTitle), PageTitle := PageTitle1
StringReplace, PageTitle, PageTitle, ', `', All
RegExMatch(title, "'(.*)'", Label), Label := Label1
pos:=1
While pos:=RegExMatch(gmailXML, "s)<entry>(.*?)</entry>", RX_Entry, pos+StrLen(RX_Entry))
Entry%A_Index% := RX_Entry1
PageText := (Label ? "Label: " . Label : PageTitle)
MsgText := (MsgText = 1 ? " unread message" : " unread messages")
InboxNN := Notify(PageText, FullCount . MsgText, TimeOut, "AC=Clicked", "data\favicon.ico")
%InboxNN% := "https://mail.google.com/mail/?shva=1#inbox"
LoopCount := (FullCount > MaxCheck ? MaxCheck : FullCount)
Loop, %LoopCount%
{
RegExMatch(Entry%A_Index%, "<title>(.*)</title>", Title), Title%A_Index% := Title1
RegExMatch(Entry%A_Index%, "href=""(.*?)""", URL), URL%A_Index% := URL1
RegExMatch(Entry%A_Index%, "<summary>(.*)</summary>", Summary), Summary%A_Index% := Summary1
StringReplace, URL%Index%, URL%Index%, &, &, All ; The & gets **** up somewhere, return it now
}
; Now, reverse the order and display, to get the mails in the right order
Loop, %LoopCount%
{
Index := LoopCount-A_Index+1 ; Counts down from Loopcount
NN := Notify(Title%Index%, Summary%Index%, TimeOut, "AC=Clicked")
%NN% := URL%Index% ; So the URL is clickable
}
FileDelete gmail.xml
Return
Clicked:
Run % %A_Gui% ; Runs the link provided by the variable assigned to the Notify() GUIs
return
PS. I put in a reservation for the app name "Maily"
