Jump to content

Recommended Posts

Posted

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

Posted

I don't think I understand what's going on really.

#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?

Posted

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
Posted

Dgameman1,

Or from the original thread in my sig. :oops:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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

Posted (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 by NiVZ
Posted

Why am I so damn confused :oops:

Rawrzz

My whole script is

#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 =/

Posted (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 by JohnQSmith

Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Posted (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 :oops:

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 :bye:, but I don't understand how to make it actually download the email attachment.

Edited by Dgameman1
Posted

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

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 Gude
How 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
Posted

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 fine

The log-in code being used has not changed since then - and if Valik says it is OK, who am I to argue? :oops:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (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 :oops:

Oh wow, stupid me, I just noticed I didn't even post the one I had modified...

Edited by ApudAngelorum
  • 2 weeks later...
Posted

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.

  • 1 month later...
Posted (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 messages

U 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 ;)

Regards

Phoenix XL

Edited 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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...