Rogue5099 Posted March 31, 2012 Posted March 31, 2012 Basically what I was trying to do was pop up a notification of unread e-mail (since atom on does unread) and then store that number. Then run the checkemail and see if the email number has changed <>. If it was > then it would only send a notification of newest email. If the number was < then the user checked their email and read/deleted the message so no notification was needed but need to store current unread emails again to see if a new email has arrived hince the $NumberofEmails > $Count My projects: Inventory / Mp3 Inventory, Computer Stats
Dgameman1 Posted April 2, 2012 Author Posted April 2, 2012 I don't think I understand what's going on really. expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..Downloadsgmail.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #Obfuscator_Parameters=/so #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <string.au3> #include "Notify.au3" #include <array.au3> Global $eReturn Global $Count Global $User = "marlboroloco" Global $Pass = "astronomicamente" _Display() _Notify_RegMsg() _Notify_Locate(0) AdlibRegister("_Display", 5000) _Notify_Set(Default) While 1 Sleep(100) WEnd Func _Display() AdlibUnRegister("_Display") $eReturn = _CheckMail($User, $Pass) Switch @error Case 0 Switch @extended Case True $Count = UBound($eReturn) - 1 For $x = 0 To $Count _Notify_Show(@AutoItExe, "", $eReturn[$x][1] & @CR & $eReturn[$x][0]) Switch @error Case 4 MsgBox(16,"text error!","Maximum text legth breached!") EndSelect Next Case False ; EndSwitch Case 1 MsgBox(0, "Error!", "Couldn't get your new emails for some reason...") Exit Case 2, 3 MsgBox(0, "Error!", "you need to enter an user name and password!") Exit Case 4 MsgBox(16, "Error!", "Error Getting URL Source!") Exit Case 5 MsgBox(16, "Error!", "No response?") Exit Case 6 MsgBox(16, "Error!", "Unauthorized access, possibly a wrong username or password!") Exit EndSwitch Return AdlibRegister("_Display", 5000) EndFunc ;==>_Display ; #FUNCTION# ==================================================================================================================== ; Name ..........: _CheckMail ; Description ...: Checks a Google Email for new emails. ; Syntax ........: _CheckMail($UserName, $Pswd[, $UserAgentString = ""]) ; Parameters ....: $UserName - An unknown value. ; $Pswd - An unknown value. ; $UserAgentString - [optional] An unknown value. Default is "". ; Return values .: A 2d array with email information as follows~ ; 1|Title ; 2|Name ; 3|Email ; 4|Summary ; 5|Date ; 6|Time ; ; Author ........: dantay9 ; Modified ......: THAT1ANONYMOUSDUDE ; Remarks .......: ; Related .......: ; Link ..........: http://www.autoitscript.com/forum/topic/...-checker/page__view__findpost_ ; Example .......: Yes ; =============================================================================================================================== Func _CheckMail($UserName, $Pswd, $UserAgentString = "") If Not $UserName Then Return SetError(2,0,0) If Not $Pswd Then Return SetError(3,0,0) If $UserAgentString Then HttpSetUserAgent($UserAgentString) Local $source = InetRead("https://" & $UserName & ":" & $Pswd & "@gmail.google.com/gmail/feed/atom",1) If @error Then ConsoleWrite("!>Error Getting URL Source!" & @CR & " 404>@Error =" & @error & @CR & " 404>@Extended =" & @extended & @CR) Return SetError(4,0,0) EndIf If $source Then $source = BinaryToString($source) Else Return SetError(5,0,0) EndIf If StringLeft(StringStripWS($source, 8), 46) == "<HTML><HEAD><TITLE>Unauthorized</TITLE></HEAD>" Then Return SetError(6, 0, 0) If Not Number(StringBetween($source, "<fullcount>", "</fullcount>")) Then Return SetError(0,0,0) Local $EmailCount = StringBetween($source, "<fullcount>", "</fullcount>") Local $Email = _StringBetween($source, "<entry>", "</entry>") If @error Then Return SetError(1, 0, 0) Local $Time Local $Datum[$EmailCount][6] $Datum[0][0] = StringBetween($source, "<title>", "</title>") $Datum[0][1] = StringBetween($source, "<tagline>", "</tagline>") For $i = 0 To $EmailCount - 1 $Datum[$i][0] = StringBetween($Email[$i], "<title>", "</title>") If Not $Datum[$i][0] Then $Datum[$i][0] = "(no subject)" $Datum[$i][1] = StringBetween($Email[$i], "<name>", "</name>") $Datum[$i][2] = StringBetween($Email[$i], "<email>", "</email>") $Datum[$i][3] = StringBetween($Email[$i], "<summary>", "</summary>") $Time = StringBetween($Email[$i], "<issued>", "</issued>") $Datum[$i][4] = DateFromTimeDate($Time) $Datum[$i][5] = TimeFromTimeDate($Time) Next Return SetError(0,$EmailCount,$Datum) EndFunc Func StringBetween($Str, $S, $E) Local $B = _StringBetween($Str, $S, $E) If @error Then Return SetError(1,0,0) Return SetError(0,0,$B[0]) EndFunc ;==>StringBetween ; #FUNCTION# ==================================================================================================================== ; Name ..........: DateFromTimeDate ; Description ...: Returns email sent date. ; Syntax ........: DateFromTimeDate($String) ; Parameters ....: $String - A gmail date string ; Return values .: None ; Author ........: ??? ; Example .......: No ; =============================================================================================================================== Func DateFromTimeDate($String) Local $RegEx = StringRegExp($String, "(?<Year>d{2}|d{4})(?:-)(?<Month>d{1,2})(?:-)(?<Day>d{1,2})", 1) If IsArray($RegEx) Then Return Int($RegEx[0]) & "/" & Int($RegEx[1]) & "/" & Int($RegEx[2]) Else Return SetError(1, 0, 0) EndIf EndFunc ;==>DateFromTimeDate ; #FUNCTION# ==================================================================================================================== ; Name ..........: TimeFromTimeDate ; Description ...: Returns the email sent time. ; Syntax ........: TimeFromTimeDate($String) ; Parameters ....: $String - An unknown value. ; Return values .: None ; Author ........: ??? ; Example .......: No ; =============================================================================================================================== Func TimeFromTimeDate($String) Local $RegEx = StringRegExp($String, "(?<Hour>d{1,2})(?::)(?<Minute>d{1,2})(?::)(?<Second>d{1,2})", 1) If IsArray($RegEx) Then Return (Int($RegEx[0]) - 4) & ":" & Int($RegEx[1]) & ":" & Int($RegEx[2]) ;don't know why I have to subtract 4 Else Return SetError(1, 0, 0) EndIf EndFunc ;==>TimeFromTimeDate So, that actually all makes sense to me except for a couple of small things but also, I don't know why the program is giving me an error about #include "Notify.au3" I don't have that, where could I get it?
Skitty Posted April 2, 2012 Posted April 2, 2012 So, that actually all makes sense to me except for a couple of small things but also, I don't know why the program is giving me an error about#include "Notify.au3"I don't have that, where could I get it?rouge5099
Moderators Melba23 Posted April 2, 2012 Moderators Posted April 2, 2012 Dgameman1, Or from the original thread in my sig. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Â
computergroove Posted April 2, 2012 Posted April 2, 2012 I can only imagine what you are trying to get emails with autoit for. I can only assume that you want to make sure that if someone has access to your email (or suspected access) that you want to make sure you get everything on a computer that that person does not have access to. If this is the case then you could use Microsoft Outlook or Mozilla Firebird and set it to check for new emails every minute. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
NiVZ Posted April 3, 2012 Posted April 3, 2012 (edited) Hello, I had to do some HTTP authentication a while back. This code will get you a valid cookie back from gmail: $Username = [email="user@gmail.com"]user@gmail.com[/email] $Password = "password" ; Create an XML HTTP object $objHTTP = ObjCreate("MSXML2.ServerXMLHTTP.6.0") ; open the POST URL for logging in $objHTTP.open ("GET", [url="https://mail.google.com/mail/feed/atom"]https://mail.google.com/mail/feed/atom[/url], false, $Username, $Password) ; Configure the proxy server address and port ;$objHTTP.setProxy("2", "ProxyIP" & ":" & "ProxyPort") ; Enter Proxy username and password ;$objHTTP.setProxyCredentials("Proxyusername", "ProxyPassword") ; Execute the Request $objHTTP.send() ; Get the session cookie $cookie = $objHTTP.getResponseHeader("Set-Cookie") ConsoleWrite("COOKIE: " & $Cookie & @CRLF) ConsoleWrite($objHTTP.ResponseText & @CRLF) You'll need to put in your own gmail email address and password, and enter any web proxy details (if you are behind a firewall) NiVZ Edited April 3, 2012 by NiVZ
Dgameman1 Posted April 3, 2012 Author Posted April 3, 2012 Why am I so damn confused Rawrzz My whole script is expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..Downloadsgmail.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #Obfuscator_Parameters=/so #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <string.au3> #include "Notify.au3" #include <array.au3> Global $eReturn Global $Count Global $User = "marlboroloco" Global $Pass = "astronomicamente" _Display() _Notify_RegMsg() _Notify_Locate(0) AdlibRegister("_Display", 5000) _Notify_Set(Default) While 1 Sleep(100) WEnd Func _Display() AdlibUnRegister("_Display") $eReturn = _CheckMail($User, $Pass) Switch @error Case 0 Switch @extended Case True $Count = UBound($eReturn) - 1 For $x = 0 To $Count _Notify_Show(@AutoItExe, "", $eReturn[$x][1] & @CR & $eReturn[$x][0]) Switch @error Case 4 MsgBox(16,"text error!","Maximum text legth breached!") EndSelect Next Case False ; EndSwitch Case 1 MsgBox(0, "Error!", "Couldn't get your new emails for some reason...") Exit Case 2, 3 MsgBox(0, "Error!", "you need to enter an user name and password!") Exit Case 4 MsgBox(16, "Error!", "Error Getting URL Source!") Exit Case 5 MsgBox(16, "Error!", "No response?") Exit Case 6 MsgBox(16, "Error!", "Unauthorized access, possibly a wrong username or password!") Exit EndSwitch Return AdlibRegister("_Display", 5000) EndFunc ;==>_Display ; #FUNCTION# ==================================================================================================================== ; Name ..........: _CheckMail ; Description ...: Checks a Google Email for new emails. ; Syntax ........: _CheckMail($UserName, $Pswd[, $UserAgentString = ""]) ; Parameters ....: $UserName - An unknown value. ; $Pswd - An unknown value. ; $UserAgentString - [optional] An unknown value. Default is "". ; Return values .: A 2d array with email information as follows~ ; 1|Title ; 2|Name ; 3|Email ; 4|Summary ; 5|Date ; 6|Time ; ; Author ........: dantay9 ; Modified ......: THAT1ANONYMOUSDUDE ; Remarks .......: ; Related .......: ; Link ..........: http://www.autoitscript.com/forum/topic/...-checker/page__view__findpost_ ; Example .......: Yes ; =============================================================================================================================== Func _CheckMail($UserName, $Pswd, $UserAgentString = "") If Not $UserName Then Return SetError(2,0,0) If Not $Pswd Then Return SetError(3,0,0) If $UserAgentString Then HttpSetUserAgent($UserAgentString) Local $source = InetRead("https://" & $UserName & ":" & $Pswd & "@gmail.google.com/gmail/feed/atom",1) If @error Then ConsoleWrite("!>Error Getting URL Source!" & @CR & " 404>@Error =" & @error & @CR & " 404>@Extended =" & @extended & @CR) Return SetError(4,0,0) EndIf If $source Then $source = BinaryToString($source) Else Return SetError(5,0,0) EndIf If StringLeft(StringStripWS($source, 8), 46) == "<HTML><HEAD><TITLE>Unauthorized</TITLE></HEAD>" Then Return SetError(6, 0, 0) If Not Number(StringBetween($source, "<fullcount>", "</fullcount>")) Then Return SetError(0,0,0) Local $EmailCount = StringBetween($source, "<fullcount>", "</fullcount>") Local $Email = _StringBetween($source, "<entry>", "</entry>") If @error Then Return SetError(1, 0, 0) Local $Time Local $Datum[$EmailCount][6] $Datum[0][0] = StringBetween($source, "<title>", "</title>") $Datum[0][1] = StringBetween($source, "<tagline>", "</tagline>") For $i = 0 To $EmailCount - 1 $Datum[$i][0] = StringBetween($Email[$i], "<title>", "</title>") If Not $Datum[$i][0] Then $Datum[$i][0] = "(no subject)" $Datum[$i][1] = StringBetween($Email[$i], "<name>", "</name>") $Datum[$i][2] = StringBetween($Email[$i], "<email>", "</email>") $Datum[$i][3] = StringBetween($Email[$i], "<summary>", "</summary>") $Time = StringBetween($Email[$i], "<issued>", "</issued>") $Datum[$i][4] = DateFromTimeDate($Time) $Datum[$i][5] = TimeFromTimeDate($Time) Next Return SetError(0,$EmailCount,$Datum) EndFunc Func StringBetween($Str, $S, $E) Local $B = _StringBetween($Str, $S, $E) If @error Then Return SetError(1,0,0) Return SetError(0,0,$B[0]) EndFunc ;==>StringBetween ; #FUNCTION# ==================================================================================================================== ; Name ..........: DateFromTimeDate ; Description ...: Returns email sent date. ; Syntax ........: DateFromTimeDate($String) ; Parameters ....: $String - A gmail date string ; Return values .: None ; Author ........: ??? ; Example .......: No ; =============================================================================================================================== Func DateFromTimeDate($String) Local $RegEx = StringRegExp($String, "(?<Year>d{2}|d{4})(?:-)(?<Month>d{1,2})(?:-)(?<Day>d{1,2})", 1) If IsArray($RegEx) Then Return Int($RegEx[0]) & "/" & Int($RegEx[1]) & "/" & Int($RegEx[2]) Else Return SetError(1, 0, 0) EndIf EndFunc ;==>DateFromTimeDate ; #FUNCTION# ==================================================================================================================== ; Name ..........: TimeFromTimeDate ; Description ...: Returns the email sent time. ; Syntax ........: TimeFromTimeDate($String) ; Parameters ....: $String - An unknown value. ; Return values .: None ; Author ........: ??? ; Example .......: No ; =============================================================================================================================== Func TimeFromTimeDate($String) Local $RegEx = StringRegExp($String, "(?<Hour>d{1,2})(?::)(?<Minute>d{1,2})(?::)(?<Second>d{1,2})", 1) If IsArray($RegEx) Then Return (Int($RegEx[0]) - 4) & ":" & Int($RegEx[1]) & ":" & Int($RegEx[2]) ;don't know why I have to subtract 4 Else Return SetError(1, 0, 0) EndIf EndFunc ;==>TimeFromTimeDate I keep getting the error (38) : ==> "EndSelect" statement with no matching "Select" statement.: EndSelect I'm sorry for being so damn retarded =/
JohnQSmith Posted April 3, 2012 Posted April 3, 2012 (edited) I'm sorry for being so damn retarded =/Yeah, that whole site auto-logon thing does seem to keep eluding you.Edit:Not only that, but you posted your username and password out there for the whole world to see. Edited April 3, 2012 by JohnQSmith Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".
Dgameman1 Posted April 3, 2012 Author Posted April 3, 2012 (edited) Yeah, that whole site auto-logon thing does seem to keep eluding you.Edit:Not only that, but you posted your username and password out there for the whole world to see.That's not my username and password, that was already in the code. I changed it back to what it was before I put it up I'm just a confused duck. I just want to be able to download an attachment from the first unread email =/Like, I'm using Rogue's script and it allows me to see the title of the unread emails on the right hand side when they appear, which is actually really cool and I'm gonna be using that from now , but I don't understand how to make it actually download the email attachment. Edited April 3, 2012 by Dgameman1
BrewManNH Posted April 3, 2012 Posted April 3, 2012 I keep getting the error (38) : ==> "EndSelect" statement with no matching "Select" statement.: EndSelect I'm sorry for being so damn retarded =/ Here's why Switch @error Case 4 MsgBox(16,"text error!","Maximum text legth breached!") EndSelect ; <<<<<<<<<<<<<< Should be EndSwitch Dgameman1 and Xandy 2 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator
Moderators Melba23 Posted April 3, 2012 Moderators Posted April 3, 2012 This thread was reported again - I refer the reporter to Valik's post #12: This seems pretty specific. The ATOM feed is read-only. The login method being used is trivial. It's also documented (though deprecated I think). It's also using a clearly supported API for programs to access as opposed to simulating a human performing a conventional login. In other words, this is fineThe log-in code being used has not changed since then - and if Valik says it is OK, who am I to argue? M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Â
Skitty Posted April 3, 2012 Posted April 3, 2012 (edited) Yeah, that whole site auto-logon thing does seem to keep eluding you. Edit: Not only that, but you posted your username and password out there for the whole world to see. Actually, I posted my I had noticed after 20 min and just changed the password when I found out...Here's why Switch @error Case 4 MsgBox(16,"text error!","Maximum text legth breached!") EndSelect ; <<<<<<<<<<<<<< Should be EndSwitch I think that was my fault if I remember correctly I was trying to figure out why some messages weren't showing and found it was that and used the code auto complete and didn't even check it Oh wow, stupid me, I just noticed I didn't even post the one I had modified... Edited April 3, 2012 by ApudAngelorum
Centaur Posted April 17, 2012 Posted April 17, 2012 being my first post i have to say "HI all:)" I have to wonder why your brute forcing your way through the web login in gmail, wouldn't be easyer to log in to the pop3 and get the mail? the atom gives you a message number you just have to retrive the messave via the message number.
PhoenixXL Posted June 10, 2012 Posted June 10, 2012 (edited) Rogue5099 ,Answer to a long back question i.e. ()I thought I would combine Melba23's Notify UDF and ApudAngelorum's Modified CheckMail UDF here to notify of a new E-mail but I'm getting stuck if someone deletes a Email then a new one arrives.Tip: U can use the Message_id for distinguishing the messagesU can get the least date of the First 20 mails using the atom feed , the messages which have a Date previous than that can be then filtered easily hope so this helps RegardsPhoenix XL Edited June 10, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now