Jump to content
Wingens

Internet Speed check and check provider

Recommended Posts

Wingens

Hi,

I am trying to create a script wich checks my hardware and my internet information.

The hardware part is done and I got my external IP-check working but I have searched far and wide but not came up wich an example for an internet speed check.

Can any one help me.
Below you will find my script:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Inet.au3>
#include <WinAPIReg.au3>
#include <Security.au3>
#include <WinAPI.au3>
#include "NavInfo.au3"

GUICreate("Mijn Salon - Check", 283, 311, -1, -1)

GUICtrlCreateGroup("Systeem info", 8, 8, 265, 145)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $PROC = GUICtrlCreateInput("", 16, 32, 249, 21)
        $READPROC = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString")
        GUICtrlSetData($PROC, $READPROC)
        GUICtrlSetState($PROC, $GUI_DISABLE)
    $RAM = GUICtrlCreateInput("RAM", 16, 56, 121, 21)
        Local $aMem = MemGetStats()
            $mem = $aMem[1] /1024
            $mem1= $mem /1024
            $mem2= Round($mem1, 0)
        GUICtrlSetData($RAM, $mem2 & " GB Geheugen")
        GUICtrlSetState($RAM, $GUI_DISABLE)
    $MODEL = GUICtrlCreateInput("", 144, 56, 121, 21)
        $READMODEL1 = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\Bios", "SystemManufacturer")
        $READMODEL2 = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\Bios", "BaseBoardProduct")
        GUICtrlSetData($MODEL, $READMODEL1 & " " & $READMODEL2)
        GUICtrlSetState($MODEL, $GUI_DISABLE)
    $WINDOWS = GUICtrlCreateInput("", 16, 80, 249, 21)
        $READOS = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName")
        If @OSArch = "X86" Then
            $ARCH = "32-Bit"
        Else
            $ARCH = "64-Bit"
        EndIf
        GUICtrlSetData($WINDOWS, $READOS & " " & $ARCH)
        GUICtrlSetState($WINDOWS, $GUI_DISABLE)
    $IE = GUICtrlCreateInput("", 16, 104, 249, 21)
        Local $sVersion = FileGetVersion(@ProgramFilesDir & "\Internet Explorer\iexplore.exe")
        GUICtrlSetData($IE, "Internet Explorer: " & $sVersion)
        GUICtrlSetState($IE, $GUI_DISABLE)
    $SILVERLIGHT = GUICtrlCreateInput("SILVERLIGHT", 16, 128, 249, 21)
        $Silverlight_Version = _NavInfo_GetSilverlightVersion()
            If Not @error Then
                GUICtrlSetData($SILVERLIGHT, "Silverlight: " & $Silverlight_Version)
            EndIf
        GUICtrlSetState($SILVERLIGHT, $GUI_DISABLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlCreateGroup("Internet info", 8, 160, 265, 113)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $SPEED = GUICtrlCreateInput("SPEED", 16, 184, 249, 21)
    $IPADRES = GUICtrlCreateInput("", 16, 216, 249, 21)
        $PublicIP = _GetIP()
        GUICtrlSetData($IPADRES, $PublicIP)
        GUICtrlSetState($IPADRES, $GUI_DISABLE)
    $PROVIDER = GUICtrlCreateInput("PROVIDER", 16, 248, 249, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$SAVE = GUICtrlCreateButton("Opslaan naar .txt", 8, 280, 131, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$MAIL = GUICtrlCreateButton("Send E-mail", 144, 280, 131, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $SAVE
            SAVE()
        Case $MAIL
            MAIL()
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func SAVE()
    $READIE     = GUICtrlRead($IE)
    $IEDONE     = StringTrimLeft($READIE, 19)
    $READSILVER = GUICtrlRead($SILVERLIGHT)
    $SILVERDONE = StringTrimLeft($READSILVER, 13)

    If FileExists(@Desktopdir & "\check.txt") Then
        FileDelete(@desktopdir & "\check.txt")
    EndIf
    $DEBITNR    = InputBox("Invoeren", "Voer klantnaam in:", "")
    $MEDEWERKER = InputBox("Invoeren", "Uitgevoerd door:", "")
    $FILE       = FileOpen(@desktopdir & "\check.txt", 1)
    $1  = GUICtrlRead($PROC)
    $2  = GUICtrlRead($RAM)
    $3  = GUICtrlRead($MODEL)
    $4  = GUICtrlRead($WINDOWS)
    $5  = $IEDONE
    $6  = $SILVERDONE
    $7  = GUICtrlRead($SPEED)
    $8  = GUICtrlRead($IPADRES)
    $9  = GUICtrlRead($PROVIDER)
        FileWrite($FILE, "Klantnaam:         " & $DEBITNR & @CRLF)
        FileWrite($FILE, "Datum:             " & @MDAY & "-" & @MON & "-" & @YEAR & @CRLF & @CRLF)
        FileWrite($FILE, "Processor:         " & $1 & @CRLF)
        FileWrite($FILE, "Geheugen:          " & $2 & @CRLF)
        FileWrite($FILE, "Model:             " & $3 & @CRLF)
        FileWrite($FILE, "Windows:           " & $4 & @CRLF)
        FileWrite($FILE, "Internet Explorer: " & $5 & @CRLF)
        FileWrite($FILE, "Silverlight:       " & $6 & @CRLF & @CRLF)
        FileWrite($FILE, "Internet Snelheid: " & $7 & @CRLF)
        FileWrite($FILE, "IP-Adres:          " & $8 & @CRLF)
        FileWrite($FILE, "Internet Provider: " & $9 & @CRLF & @CRLF)
        FileWrite($FILE, "Uitgevoerd door:   " & $MEDEWERKER)

MsgBox(4096, "Klaar", "Check is klaar en opgeslagen op het bureaublad")
EndFunc

Func MAIL()

EndFunc

 

Share this post


Link to post
Share on other sites
Wingens

I'm losing hope here...maybe i could use a third party software? Anyone got any ideas for me...

Share this post


Link to post
Share on other sites
argumentum

I'm losing hope here...maybe i could use a third party software? Anyone got any ideas for me...

​...just got to read this. Haven't test your code, but, you'll need a place to upload a file to, then calculate how much data per second. or how long it took to upload.
Have faith, or perseverance, or patients, ...my technic is random try. You can code it all with the tools on the site. Don't give up. Do a search maybe you'll find something close to what you envision. 

Share this post


Link to post
Share on other sites
argumentum

the same UDF creator also made https://www.autoitscript.com/forum/topic/149083-netinfo-udf/ that does what you want.
But it has issues, at line 247 you'll need to replace it with If UBound($aRegex) - 1 <> 7 Then Return SetError(1, 0, $aReturn) or at failure point it'll stop the script.

Hope this brings the morale up  =D

Share this post


Link to post
Share on other sites
Wingens

It gives me some hope but i think i am doing something wrong, i editted the line 247 like you said:

Func _NetInfo_GetIPLocation()
    Local $aReturn[4], $bRead, $sRead, $aRegex
    $bRead = InetRead("http://www.ip-tracker.org/track-ip-api.php")
    $sRead = BinaryToString($bRead)
    $aRegex = StringRegExp($sRead, '<b>(.*?)</b>', 3)
    If UBound($aRegex) - 1 <> 7 Then Return SetError(1, 0, $aReturn)
;   If UBound($aRegex) - 1 <> 7 Then Return SetError(1, 0, "")
    $aReturn[0] = $aRegex[0]
    $aReturn[1] = $aRegex[1]
    $aReturn[2] = $aRegex[4]
    $aReturn[3] = $aRegex[5]

    Return $aReturn
EndFunc   ;==>_NetInfo_GetIPLocation

And i think i added the correct code to the script but i am missing something...

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Inet.au3>
#include <WinAPIReg.au3>
#include <Security.au3>
#include <WinAPI.au3>
#include <NavInfo.au3>
#include <Netinfo.au3>

TrayTip("Mijn Salon - Check", "Bezig met opstarten...", 3)
    Sleep(3000)

GUICreate("Mijn Salon - Check", 283, 311, -1, -1)

GUICtrlCreateGroup("Systeem info", 8, 8, 265, 145)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    TrayTip("Mijn Salon - Check", "Bezig met uitlezen processor informatie...", 3)
        Sleep(1500)
    $PROC = GUICtrlCreateInput("", 16, 32, 249, 21)
        $READPROC = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString")
        GUICtrlSetData($PROC, $READPROC)
        GUICtrlSetState($PROC, $GUI_DISABLE)
    TrayTip("Mijn Salon - Check", "Bezig met uitlezen geheugen capaciteit...", 3)
        Sleep(1500)
    $RAM = GUICtrlCreateInput("", 16, 56, 121, 21)
        Local $aMem = MemGetStats()
            $mem = $aMem[1] /1024
            $mem1= $mem /1024
            $mem2= Round($mem1, 0)
        GUICtrlSetData($RAM, $mem2 & " GB Geheugen")
        GUICtrlSetState($RAM, $GUI_DISABLE)
    TrayTip("Mijn Salon - Check", "Bezig met uitlezen model informatie...", 3)
        Sleep(1500)
    $MODEL = GUICtrlCreateInput("", 144, 56, 121, 21)
        $READMODEL1 = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\Bios", "SystemManufacturer")
        $READMODEL2 = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\Bios", "BaseBoardProduct")
        GUICtrlSetData($MODEL, $READMODEL1 & " " & $READMODEL2)
        GUICtrlSetState($MODEL, $GUI_DISABLE)
    TrayTip("Mijn Salon - Check", "Bezig met uitlezen Windows versie...", 3)
        Sleep(1500)
    $WINDOWS = GUICtrlCreateInput("", 16, 80, 249, 21)
        $READOS = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName")
        If @OSArch = "X86" Then
            $ARCH = "32-Bit"
        Else
            $ARCH = "64-Bit"
        EndIf
        GUICtrlSetData($WINDOWS, $READOS & " " & $ARCH)
        GUICtrlSetState($WINDOWS, $GUI_DISABLE)
    TrayTip("Mijn Salon - Check", "Bezig met uitlezen Internet Explorer versie...", 3)
        Sleep(1500)
    $IE = GUICtrlCreateInput("", 16, 104, 249, 21)
        Local $sVersion = FileGetVersion(@ProgramFilesDir & "\Internet Explorer\iexplore.exe")
        GUICtrlSetData($IE, "Internet Explorer: " & $sVersion)
        GUICtrlSetState($IE, $GUI_DISABLE)
    TrayTip("Mijn Salon - Check", "Bezig met uitlezen Silverlight versie...", 3)
        Sleep(1500)
    $SILVERLIGHT = GUICtrlCreateInput("SILVERLIGHT", 16, 128, 249, 21)
        $Silverlight_Version = _NavInfo_GetSilverlightVersion()
            If Not @error Then
                GUICtrlSetData($SILVERLIGHT, "Silverlight: " & $Silverlight_Version)
            EndIf
        GUICtrlSetState($SILVERLIGHT, $GUI_DISABLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlCreateGroup("Internet info", 8, 160, 265, 113)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $SPEED = GUICtrlCreateInput("", 16, 184, 249, 21)
    TrayTip("Mijn Salon - Check", "Bezig met het testen van internet snelheid...", 3)
        Sleep(1500)
        $SPEEDCHECK = _NetInfo_GetDownloadSpeed()
        GUICtrlSetData($SPEED, $SPEEDCHECK)
        GUICtrlSetState($SPEED, $GUI_DISABLE)
    TrayTip("Mijn Salon - Check", "Bezig met opvragen IP-Adres...", 3)
        Sleep(1500)
    $IPADRES = GUICtrlCreateInput("", 16, 216, 249, 21)
        $PublicIP = _GetIP()
        GUICtrlSetData($IPADRES, $PublicIP)
        GUICtrlSetState($IPADRES, $GUI_DISABLE)
    $PROVIDER = GUICtrlCreateInput("", 16, 248, 249, 21)
    TrayTip("Mijn Salon - Check", "Bezig met opvragen provider naam...", 3)
        Sleep(1500)
        $VAR =  _NetInfo_GetISP()
        GUICtrlSetData($PROVIDER, $VAR)
        GUICtrlSetState($PROVIDER, $GUI_DISABLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$SAVE = GUICtrlCreateButton("Opslaan naar .txt", 8, 280, 131, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$MAIL = GUICtrlCreateButton("Send E-mail", 144, 280, 131, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
        GUICtrlSetState($MAIL, $GUI_DISABLE)

    TrayTip("Mijn Salon - Check", "Controles zijn klaar...", 3)
        Sleep(1500)

GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $SAVE
            SAVE()
        Case $MAIL
            MAIL()
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func SAVE()
    $READIE     = GUICtrlRead($IE)
    $IEDONE     = StringTrimLeft($READIE, 19)
    $READSILVER = GUICtrlRead($SILVERLIGHT)
    $SILVERDONE = StringTrimLeft($READSILVER, 13)

    If FileExists(@Desktopdir & "\check.txt") Then
        FileDelete(@desktopdir & "\check.txt")
    EndIf
    $DEBITNR    = InputBox("Invoeren", "Voer klantnaam in:", "")
    $MEDEWERKER = InputBox("Invoeren", "Uitgevoerd door:", "")
    $FILE       = FileOpen(@desktopdir & "\check.txt", 1)
    $1  = GUICtrlRead($PROC)
    $2  = GUICtrlRead($RAM)
    $3  = GUICtrlRead($MODEL)
    $4  = GUICtrlRead($WINDOWS)
    $5  = $IEDONE
    $6  = $SILVERDONE
    $7  = GUICtrlRead($SPEED)
    $8  = GUICtrlRead($IPADRES)
    $9  = GUICtrlRead($PROVIDER)
        FileWrite($FILE, "Klantnaam:         " & $DEBITNR & @CRLF)
        FileWrite($FILE, "Datum:             " & @MDAY & "-" & @MON & "-" & @YEAR & @CRLF & @CRLF)
        FileWrite($FILE, "Processor:         " & $1 & @CRLF)
        FileWrite($FILE, "Geheugen:          " & $2 & @CRLF)
        FileWrite($FILE, "Model:             " & $3 & @CRLF)
        FileWrite($FILE, "Windows:           " & $4 & @CRLF)
        FileWrite($FILE, "Internet Explorer: " & $5 & @CRLF)
        FileWrite($FILE, "Silverlight:       " & $6 & @CRLF & @CRLF)
        FileWrite($FILE, "Internet Snelheid: " & $7 & @CRLF)
        FileWrite($FILE, "IP-Adres:          " & $8 & @CRLF)
        FileWrite($FILE, "Internet Provider: " & $9 & @CRLF & @CRLF)
        FileWrite($FILE, "Uitgevoerd door:   " & $MEDEWERKER)

MsgBox(4096, "Klaar", "Check is klaar en opgeslagen op het bureaublad")
EndFunc

Func MAIL()
    $READIE     = GUICtrlRead($IE)
    $IEDONE     = StringTrimLeft($READIE, 19)
    $READSILVER = GUICtrlRead($SILVERLIGHT)
    $SILVERDONE = StringTrimLeft($READSILVER, 13)
    $DEBITNR    = InputBox("Invoeren", "Voer klantnaam in:", "")
    $MEDEWERKER = InputBox("Invoeren", "Uitgevoerd door:", "")

    $1  = GUICtrlRead($PROC)
    $2  = GUICtrlRead($RAM)
    $3  = GUICtrlRead($MODEL)
    $4  = GUICtrlRead($WINDOWS)
    $5  = $IEDONE
    $6  = $SILVERDONE
    $7  = GUICtrlRead($SPEED)
    $8  = GUICtrlRead($IPADRES)
    $9  = GUICtrlRead($PROVIDER)
;   $VAR = "Klantnaam:         " & $DEBITNR & @CRLF)
;   $VAR1 = "Datum:             " & @MDAY & "-" & @MON & "-" & @YEAR & @CRLF & @CRLF)
;   $VAR2 = "Processor:         " & $1 & @CRLF)
;   $VAR3   = "Geheugen:          " & $2 & @CRLF)
;   $VAR4   = "Model:             " & $3 & @CRLF)
;   $VAR5   = "Windows:           " & $4 & @CRLF)
;   $VAR6   = "Internet Explorer: " & $5 & @CRLF)
;   $VAR7   = "Silverlight:       " & $6 & @CRLF & @CRLF)
;   $VAR8   = "Internet Snelheid: " & $7 & @CRLF)
;   $VAR9   = "IP-Adres:          " & $8 & @CRLF)
;   $VAR10  = "Internet Provider: " & $9 & @CRLF & @CRLF)
;   $VAR11  = "Uitgevoerd door:   " & $MEDEWERKER)

$SENDMAIL = _INetSmtpMail("smtp.orange.net", "mijnSalon-Check", "m.wingens87@gmail.com", "m.wingens87@gmail.com", "mijnSalon-check", "Test")
    If $SENDMAIL = 1 Then
        MsgBox(4096, "Gelukt", "Mail verzonden.")
    Else
        MsgBox(4096, "Fout", "Mail niet verzonden gebruik opslaan naar .txt")
    EndIf
EndFunc

 

Share this post


Link to post
Share on other sites
argumentum

And i think i added the correct code to the script but i am missing something...

​as far as I see the code runs without problems. I'd save the file to @MyDocumentsDir but is no big deal

Share this post


Link to post
Share on other sites
Wingens

Thats strange, when i run the exact same script, get nothing with the: _NetInfo_GetDownloadSpeed()

And i get a 0 with: _NetInfo_GetISP() , after checking the UDF this means it fails to check the ISP but when i go the url, this works perfectly.

 

Naamloos.png

Share this post


Link to post
Share on other sites
Scripthen

Best way to measure upload will be with FTP transactions. I don't know if this will be a personal program or released to public.
If it's personal, find a "free" web server or a cheap VPS for a private FTP server.

As for Download, same again or you can also create an array of web links that direct to "ISP Test" pages and download a variable 2 - 100MB - same again for ping, and just simply use the ping() function.

Also, as you'll be testing net speeds and connections, it might be a good idea to shorten the code and code a PHP page which displays *most* data relevant to you.

 

Can't really help out on the coding but there's some ideas for you.

Share this post


Link to post
Share on other sites
Wingens

Got the download speed check working now i am struggeling with the ISP check.

GUICtrlCreateGroup("Internet info", 8, 160, 265, 113)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $SPEED = GUICtrlCreateInput("", 16, 184, 249, 21)
    TrayTip("Mijn Salon - Check", "Bezig met het testen van internet snelheid...", 3)
        Sleep(1500)
        $SPEEDCHECK = _NetInfo_GetDownloadSpeed()
            $VAR1 = _ArrayExtract($SPEEDCHECK, 1, 1)
            $VAR2 = _ArrayToString($VAR1, 1)
            $VAR3 = $VAR2 /100
        GUICtrlSetData($SPEED, $VAR3 & " MBit")
        GUICtrlSetState($SPEED, $GUI_DISABLE)
    TrayTip("Mijn Salon - Check", "Bezig met opvragen IP-Adres...", 3)
        Sleep(1500)
    $IPADRES = GUICtrlCreateInput("", 16, 216, 249, 21)
        $PublicIP = _GetIP()
        GUICtrlSetData($IPADRES, $PublicIP)
        GUICtrlSetState($IPADRES, $GUI_DISABLE)
    $PROVIDER = GUICtrlCreateInput("", 16, 248, 249, 21)
    TrayTip("Mijn Salon - Check", "Bezig met opvragen provider naam...", 3)
        Sleep(1500)
        $ISPCHECK =  _NetInfo_GetISP()
        GUICtrlSetData($PROVIDER, $ISPCHECK)
        GUICtrlSetState($PROVIDER, $GUI_DISABLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)

 

Share this post


Link to post
Share on other sites
Wingens

I decided to drop the ISP check, now i am aiming at sending the e-mail. using gmail account.

 

Thx for the support.

Right now this is what i am using for SMTP, i know it is offtopic but maybe some one who is following this thread find it use full.

;
;##################################
; Include
;##################################
#Include<file.au3>
;##################################
$SmtpServer = ""              ; address for the smtp-server to use - REQUIRED
$FromName = ""      ; name from who the email was sent
$FromAddress = ""   ; address from where the mail should come
$ToAddress = ""             ; destination address of the email - REQUIRED
$Subject = ""                   ; subject from the email - can be anything you want it to be
$Body = ""          ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = ""   ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
$CcAddress = ""                             ; address for cc - leave blank if not needed
$BccAddress = ""                            ; address for bcc - leave blank if not needed
$Importance = "Normal"                      ; Send message priority: "High", "Normal", "Low"
$Username = "****"      ; username for the account used from where the mail gets sent - REQUIRED
$Password = "****"                      ; password for the account used from where the mail gets sent - REQUIRED
;$IPPort = 25                               ; port used for sending the mail
;$ssl = 0                                   ; enables/disables secure socket layer sending - put to 1 if using httpS
$IPPort=465                                 ; GMAIL port used for sending the mail
$ssl=1                                      ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)
EndIf
;##################################
; The UDF
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
        $objEmail.HTMLBody = $as_Body
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
;~          ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
            If FileExists($S_Files2Attach[$x]) Then
                ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF)
                $objEmail.AddAttachment($S_Files2Attach[$x])
            Else
                ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set Email Importance
    Switch $s_Importance
        Case "High"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
        SetError(2)
        Return $oMyRet[1]
    EndIf
    $objEmail=""
EndFunc   ;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
EndFunc   ;==>MyErrFunc

 

Share this post


Link to post
Share on other sites
Jos

I decided to drop the ISP check, now i am aiming at sending the e-mail. using gmail account.

 

Thx for the support.

Right now this is what i am using for SMTP, i know it is offtopic but maybe some one who is following this thread find it use full.expandpopup

Trying to understand what you are sharing with this post other than somebody else his UDF?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • HardXOR
      By HardXOR
      Hello AutoIt community
      I run into speed problem in my script wich i cant solve myself, problem is with decoding texture loop - for better explanation, you need extract from file pallete (16x 16 RGB color) and picture data (224 * 128 byte), then use correct color for your picture data.... nothing extra hard and also texture is quite small 224*256
      it is for my car model viewer/later maybe editor GranTurismo 2 from Playstation 1, so its old dataformat and i cant understand why AutoIt take so long to decode texture when good old Playstation almost 2,5 decades old can do that nearly immediately (when you list through cars in shop or garage)
      My first atempt was create all trought dllstructure, because its easier approach, but it was soooo slow (40-50s for create textures) then i upgrade my routine via arrays, first 3D arrays later only 1D, next i put decoding colors outside loop but it is still not enough, my last version took cca 15s wich is still unacceptable for car model viewer when you click on one carmodel from listview (1100 cars for whole game) and you must wait 15-16s for model to load....  oh and i forgot mention some cars have more then 1 color (much more... 8-9-10 etc) soloading take 8-9-10 times more time
      in attachment i post texture file from GranTurismo 2 for one car (contain only 1 color) and also my dll struct version and array version code
      dll struct version - ± 40 sec (33 without saving)
      #include <FileConstants.au3> Global $IMDT[256][256][4] LoadTexture("ufs9r.cdp") Func LoadTexture($file) $fileHandle = FileOpen($file, $FO_BINARY) $header = FileRead($fileHandle, 0x20) ConsoleWrite("header> " & $header & @CRLF) $PAL = FileRead($fileHandle, 0x200) ConsoleWrite("PAL> " & $PAL & @CRLF) FileSetPos($fileHandle, 0x43A0, $FILE_BEGIN) $IMD = FileRead($fileHandle, 0x7000) ConsoleWrite("IMD> " & $IMD & @CRLF) $st = DllStructCreate("BYTE[512]") DllStructSetData($st, 1, $PAL) $struct_PAL = DllStructCreate("WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16]", DllStructGetPtr($st)) $struct_IMD = DllStructCreate("BYTE[" & 0x7000 & "]") DllStructSetData($struct_IMD, 1, $IMD) $start = TimerInit() For $i = 0 To 15 For $j = 0 To 223 $cn = 0 For $k = 0 To 127 $bt = DllStructGetData($struct_IMD, 1, $j * 128 + $k + 1) $blue = BitShift(DllStructGetData($struct_PAL, $i + 1, BitAND($bt, 0x0F) + 1), 7) $IMDT[$j][$cn][0] = $blue $green = BitShift(DllStructGetData($struct_PAL, $i + 1, BitAND($bt, 0x0F) + 1), 2) $IMDT[$j][$cn][1] = $green $red = BitShift(DllStructGetData($struct_PAL, $i + 1, BitAND($bt, 0x0F) + 1), - 3) $IMDT[$j][$cn][2] = $red If DllStructGetData($struct_PAL, $i + 1, BitAND($bt, 0x0F) + 1) = 0 Then $IMDT[$j][$cn][3] = 0x00 Else $IMDT[$j][$cn][3] = 0xFF EndIf $cn += 1 $blue = BitShift(DllStructGetData($struct_PAL, $i + 1, BitShift($bt, 4) + 1), 7) $IMDT[$j][$cn][0] = $blue $green = BitShift(DllStructGetData($struct_PAL, $i + 1, BitShift($bt, 4) + 1), 2) $IMDT[$j][$cn][1] = $green $red = BitAND(BitShift(DllStructGetData($struct_PAL, $i + 1, BitShift($bt, 4) + 1), - 3), 0xFF) $IMDT[$j][$cn][2] = $red If DllStructGetData($struct_PAL, $i + 1, BitShift($bt, 4) + 1) = 0 Then $IMDT[$j][$cn][3] = 0x00 Else $IMDT[$j][$cn][3] = 0xFF EndIf $cn += 1 Next Next saveTGA($i) Next ConsoleWrite("t " & TimerDiff($start) & @CRLF) ; +- 40 seconds FileClose($fileHandle) EndFunc Func saveTGA($name) Local $tga[18] = [0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x20, 0x20] Local $data for $i = 0 To 17 $data &= Hex($tga[$i], 2) Next For $i = 0 To 255 For $j = 0 To 255 For $k = 0 To 3 $data &= hex($IMDT[$i][$j][$k], 2) Next Next Next $binary = FileOpen("test\" & $name & ".tga", BitOR($FO_BINARY, $FO_OVERWRITE, $FO_CREATEPATH)) FileWrite($binary, "0x" & $data) FileClose($binary) EndFunc  
      array version - ± 15 sec (under 10s without saving)
      #include <FileConstants.au3> LoadTexture2("ufs9r.cdp") Func LoadTexture2($file) $fileHandle = FileOpen($file, $FO_BINARY) $a = TimerInit() Global $header[0x20] For $i = 0 To UBound($header) - 1 $header[$i] = Int(String(FileRead($fileHandle, 1))) ; read 0x20 bytes Next ConsoleWrite("header " & TimerDiff($a) & @CRLF) $a = TimerInit() Global $PAL[0x100] For $i = 0 To UBound($PAL) - 1 $PAL[$i] = Number(FileRead($fileHandle, 2)) ; read 0x200 (16*16) words Next Global $PALcolor[16 * 16 * 4] For $i = 0 To UBound($PAL) - 1 $PALcolor[$i * 4 + 0] = BitShift($PAL[$i], 7) $PALcolor[$i * 4 + 1] = BitShift($PAL[$i], 2) $PALcolor[$i * 4 + 2] = BitShift($PAL[$i], -3) If $PAL[$i] = 0 Then $PALcolor[$i * 4 + 3] = 0x00 Else $PALcolor[$i * 4 + 3] = 0xFF EndIf Next ConsoleWrite("PAL " & TimerDiff($a) & @CRLF) $a = TimerInit() FileSetPos($fileHandle, 0x43A0, $FILE_BEGIN) Global $IMD[0x7000] For $i = 0 To UBound($IMD) - 1 $IMD[$i] = Int(String(FileRead($fileHandle, 1))) ; read 0x7000 bytes Next ConsoleWrite("IMD " & TimerDiff($a) & @CRLF) Global $IMDT[256*256*4] $a = TimerInit() For $i = 0 To 15 For $j = 0 To 223 $cn = 0 For $k = 0 To 127 $byte = $IMD[$j * 128 + $k] ; byte for decode $index = $j * 1024 + $cn * 4 $index2 = $i * 0x40 + BitAND($byte, 0x0F) * 4 $IMDT[$index + 0] = $PALcolor[$index2 + 0] ; blue $IMDT[$index + 1] = $PALcolor[$index2 + 1] ; green $IMDT[$index + 2] = $PALcolor[$index2 + 2] ; red $IMDT[$index + 3] = $PALcolor[$index2 + 3] ; alpha $cn += 1 $index = $j * 1024 + $cn * 4 $index2 = $i * 0x40 + BitShift($byte, 4) * 4 $IMDT[$index + 0] = $PALcolor[$index2 + 0] ; blue $IMDT[$index + 1] = $PALcolor[$index2 + 1] ; green $IMDT[$index + 2] = $PALcolor[$index2 + 2] ; red $IMDT[$index + 3] = $PALcolor[$index2 + 3] ; alpha $cn += 1 Next Next ;~ $b = TimerInit() saveTGA2($i) ;~ ConsoleWrite("save TGA " & TimerDiff($b) & @CRLF) Next ConsoleWrite("full time " & TimerDiff($a) & @CRLF) ; 16 seconds FileClose($fileHandle) EndFunc Func saveTGA2($name) Local $tga[18] = [0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x20, 0x20] Local $data For $i = 0 To 17 $data &= Hex($tga[$i], 2) Next For $i = 0 To UBound($IMDT) - 1 $data &= Hex($IMDT[$i], 2) Next $binary = FileOpen("test\" & $name & ".tga", BitOR($FO_BINARY, $FO_OVERWRITE, $FO_CREATEPATH)) FileWrite($binary, "0x" & $data) FileClose($binary) EndFunc if anyone can optimize my code I would be very grateful, or pointing me to better solution, thx
      ufs9r.cdp
    • nacerbaaziz
      By nacerbaaziz
      Detect if the focus item is a button or check box
      Hello everyone.
      My dears I have a problem
      When I try to use
      ControlGetFocus function
      it  doesn't recognize the check  boxes.
      The result is that the selector is a button
      Although the specified is a check box
      but I want a way to identify the check boxes.
      Because I want to make a tool that helps screen readers users
      I hope you have the solution.
      Thank you in advance.
       
    • Triblade
      By Triblade
      Hi all,
       
      I was pondering over a question with regards to the speeds of reading something and did not see this kind of question in a forum search.
      The question: What is (technically) faster? Multiple reads from the same 3d array cell, or only once make a 'temp' variable from that cell and read the value from this? I don't know if either has any real impact at all anyway, but just wanted to ask anyway. :-)
       
      There may be a difference if the value holds an integer or a string (or something else) but in my case, is a simple integer.
      To hopefully clarify with a small bit of code:
      $process = $start - 15 If $xy[$process][3] <> "x" Then If _ArraySearch($open, $process, 1, $open[0][0], 0, 0, 1, 1) <> -1 Then UpdateOpen($xy[$process][5], $closed[0][0]) ElseIf $start > 0 And _ArraySearch($closed, $process, 1, $closed[0][0], 0, 0, 1, 0) = -1 Then Add_open($start, $closed[0][0], $counter, $process) EndIf EndIf You can read from this, that the array $closed[0][0] is being read 3 times. And this goes on further in the code I did not show.
      My question boils down to this, should I make a 'temp' variable to hold that $closed[0][0] value until the function is done?
       
      It may not have a real impact on my small script, but I really am interested in the answer at least.
       
      Regards,
      Tri.
    • Jdr
      By Jdr
      I'm trying to check for the existance of a file, on logon the file is there, then gets deleted and after a while recreated. I'm using this code:
      Sleep(100) If not FileExists($sFile) Then Sleep(150) If FileExists($sFile) Then GUICtrlSendToDummy($iDummy) What happens is this: 
      User logs on, the file is present, or at least it usually is After about 10 seconds the file gets deleted Then after about 50 seconds the file gets created again, this is when I need the check, because now the process is finished. The above code is part of a pretty long do....until false loop running an animation.
      The problem is that sometimes this code fails. Without the sleep statements it didn't work at all so I think this is a timing issue. Pretty primitive code I admit, there must be a better way...
       
    • Grosminet
      By Grosminet
      Searching inside the forum, I don't succeed to get any explanation about a strange (for me !) phenomena:
      Using AutoIt, I have coded a "cortex of neurons Simulator" for which I handle several neurons activity (Action Potential and Postsynaptic Potential) which take a long time, about 20 ms per neuron to be processed. This is why I need a global loop running about 1s for a global cortex of 50 neurons.
      But when I move the mouse (in any direction, like rotating above the GUI) the speed of the loop increase significantly : around x8 times more ... !
      This happens only if the GUI has the focus. I did a check with the "Windows Task Manager" where I can see the CPU usage changing every time the mouse is moving (growing from 3% to 15%).
      I believe to remember some lecture about the influence of the user events regarding the "Application" capability to anticipate user actions by changing it's rate of pooling events, but I'm not sure it was in an AutoIt forum, or maybe it was in an other "developer forum" (like "Code Project", "Stackoverflow" , or ...?
      Could somebody help me to understand this behaviour ?
      If possible, is there a programmatic method to manage the speed of a simple "For, Next" loop ? I try to change the Application priority (setting to level 4 with "ProcessSetPriority"), but this seems not very efficient ....
      Thanks, Alain.

      FYI: I'm using :
      Autoit 3.3.14.2 Windows 7 Home Premium Service Pack 1 Computer ASUS N56V Screen resolution: 1920x1080 (recommended) Theme :Windows Classic
×