Jump to content

Help With Progress Bar


Eambo
 Share

Recommended Posts

Hi everyone :-)

I was hoping someone could help me find where I'm going wrong. I'm literally trying to use the code listed on the help page:

Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", @TempDir & "\update.dat", 1, 1)
Do
    Sleep(250)
Until InetGetInfo($hDownload, 2)    ; Check if the download is complete.
Local $aData = InetGetInfo($hDownload)  ; Get all information.
InetClose($hDownload)   ; Close the handle to release resourcs.
MsgBox(0, "", "Bytes read: " & $aData[0] & @CRLF & _
    "Size: " & $aData[1] & @CRLF & _
    "Complete?: " & $aData[2] & @CRLF & _
    "Successful?: " & $aData[3] & @CRLF & _
    "@error: " & $aData[4] & @CRLF & _
    "@extended: " & $aData[5] & @CRLF)

I was thinking in order to get this to work I would simply need to change the URL - however it doesn't display anything! My downloader downloads, I can watch the file downloading to the directory, however the progress never shows. Has anyone got any suggestions on why this would be?

Thank you once again for your help and support :-)

Link to comment
Share on other sites

  • Moderators

I'm a bit confused by your title. You seem to be requesting help with a progress bar, but your example is using the inetget function. For inetget, there is no built in progress bar as it downloads. If you open the sample script in the help file, you'll see it downloads the file(s) and then displays the msgbox. For a progress bar you'll need to look under ProgressOn. If this is not your intent, please post some clarification so we can assist further.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

InetGet() doesn't display anything unless you take the data that is secretly created by InetGetInfo($hDownload, 0) << this is the bytes read so far, have a look at GUICtrlCreateProgress() and GUICtrlSetData() in the Help File and have a look in the forum by searching InetGetInfo + ProgressBar.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

ah, I think I may be confusing myself then :-)

I thought the above displayed while downloading, for example complete I figured would show no if still downloading.

I was previously toying with this scriptlet:

InetGet($FileURL,$FileName,0,1)
 
ProgressOn("","")
While @InetGetActive
    $Percentage = @InetGetBytesRead * 100 / $FileSize
    ProgressSet($Percentage,"Downloaded " & @InetGetBytesRead & " of " & $FileSize & " bytes","Downloading " & $FileName)
    Sleep(250)
Wend
ProgressOff()

But I'm assuming some of these functions have since been retired, as I couldn't get this one to work :-(

I may be looking in the wrong place, but I can't find much on ProgressOn, which is exactly what I'm looking for. Does it still exist?

Link to comment
Share on other sites

  • Moderators

I've always used ProgressOn, ProgressSet and ProgressOff, but Guinness is correct that it can be done other ways as well. Below is something I located in the forums (proper credit to wakillon for this script).

#include <Math.au3> 
    
$_FinalUrl = 'http://www.birdscanfly.com/images/bcf_wallpaper_1440.jpg'
$_TempPath = @TempDir & '\bcf_wallpaper_1440.jpg'
$_FileSize = InetGetSize ( $_FinalUrl )
$_Gui = GUICreate ( "" )
$_ProgressBar = GUICtrlCreateProgress ( 5, 25, 350, 23 )
GUISetState ( @SW_SHOW )
$_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1 )
Local $_InfoData
Do
    $_InfoData = InetGetInfo ( $_Download )
    If Not @error Then
        $_InetGet = $_InfoData[0]
        $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize )
        $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 99 )
        GUICtrlSetData ( $_ProgressBar, $_DownloadPercent )
        $_Label = GUICtrlCreateLabel ( 'progress : ' & $_DownloadPercent & ' %', 5, 52, 350, 20 )  
    EndIf
    Sleep ( 100 )    
Until $_InfoData[2] = True
$_Label = GUICtrlCreateLabel ( 'Download successfull !', 5, 52, 350, 20 )  
Sleep ( 2000 )

I think I'm going to start using this for some of my old scripts as well. Hope it helps.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thanks JLogan :-)

Out of interest, does ProgressOn/Off still work? It looks like a very simplistic version, pretty much perfect for me. I honestly haven't done too much with GUI and I'm not sure if I want to dive into that just yet - unless of course it's a necessity for a progress indicator.

Link to comment
Share on other sites

  • Moderators

Yes, I use it often. From the help file:

ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
 sleep(1000)
 ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I don't suppose you know what's wrong with the code I posted previously? Namely:

InetGet($FileURL,$FileName,0,1)
 
ProgressOn("","")
While @InetGetActive
    $Percentage = @InetGetBytesRead * 100 / $FileSize
    ProgressSet($Percentage,"Downloaded " & @InetGetBytesRead & " of " & $FileSize & " bytes","Downloading " & $FileName)
    Sleep(250)
Wend
ProgressOff()

When I use this, it acts exactly the same as if I remove everything but the INetGet line. Essentially it downloads, but shows no progress. I also have a msgbox after the INetGet, which doesn't kick in until the download is complete - I'm wondering if this is related? It seems as though it hits INetGet, and does not continue until the download is complete. Could this be because I haven't set the backgrounding properties correctly? I don't fully understand the backgrounding, so I didn't set any parameters for it in my own code.

Thanks for your time!

Link to comment
Share on other sites

What Version of AutoIt are you using? Because I have V3.3.6.1 and @InetGetActive is no longer used in this Version, the clues were in JLogan3o13's Version :x

Have a look at this though :P Hope it's what you wanted?!

Function:

; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
; #INDEX# =======================================================================================================================
; Title .........: _InetGetProgress
; AutoIt Version : v3.3.2.0 or higher
; Language ......: English
; Description ...: Download a file showing a progress bar using ProgressOn.
; Note ..........:
; Author(s) .....: guinness
; Remarks .......:
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
; _InetGetProgress: Download a file showing a progress bar using ProgressOn.
; ===============================================================================================================================

; #INTERNAL_USE_ONLY#============================================================================================================
; _ByteSuffix ......; Convert bytes to the largest measure. Thanks to Spliff69 - http://www.autoitscript.com/forum/topic/116897-folder-sync-tool/page__view__findpost__p__815328
; ===============================================================================================================================

; #FUNCTION# =========================================================================================================
; Name...........: _InetGetProgress()
; Description ...: Download a file showing a progress bar using ProgressOn.
; Syntax.........: _InetGetProgress($sURL, [$sDirectory = @ScriptDir])
;                 $sURL - A valid URL that contains the filename too.
;                 $sDirectory - [Optional] Directory of where to download to @ScriptDir
; Parameters ....: None
; Requirement(s).: v3.3.2.0 or higher
; Return values .: Success - Downloaded filename.
;                  Failure - Returns downloaded filename & sets @error = 1
; Author ........: guinness
; Example........; Yes
;=====================================================================================================================
Func _InetGetProgress($sURL, $sDirectory = @ScriptDir)
    Local $hDownload, $iBytesRead = 0, $iFileSize, $iPercentage, $iSpeed = 0, $iTimer = 0, $sFilePath, $sProgressText, $sSpeed
    $sFilePath = StringRegExpReplace($sURL, "^.*/", "")
    If @error Then
        Return SetError(1, 0, $sFilePath)
    EndIf

    $sDirectory = StringRegExpReplace($sDirectory, "[\\/]+\z", "") & "\" & $sFilePath
    $iFileSize = InetGetSize($sURL, 1)
    $hDownload = InetGet($sURL, $sDirectory, 0, 1)
    If @error Then
        Return SetError(1, 0, $sFilePath)
    EndIf
    ProgressOn("", "")

    $sSpeed = "Current Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
    $iTimer = TimerInit()
    While InetGetInfo($hDownload, 2) = 0
        $iBytesRead = InetGetInfo($hDownload, 0)
        $iPercentage = $iBytesRead * 100 / $iFileSize
        $sProgressText = "Downloading " & _ByteSuffix($iBytesRead, 0) & " Of " & _ByteSuffix($iFileSize, 0) & @LF & $sSpeed
        ProgressSet(Round($iPercentage, 0), $sProgressText, "Downloading: " & $sFilePath)

        If TimerDiff($iTimer) > 1000 Then
            $sSpeed = "Current Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
            $iSpeed = $iBytesRead
            $iTimer = TimerInit()
        EndIf
        Sleep(100)
    WEnd
    InetClose($hDownload)
    ProgressOff()
    Return $sFilePath
EndFunc   ;==>_InetGetProgress

; #INTERNAL_USE_ONLY#============================================================================================================
Func _ByteSuffix($iBytes, $iRound = 2)
    Local $A, $aArray[9] = [" B", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"]
    While $iBytes > 1023
        $A += 1
        $iBytes /= 1024
    WEnd
    Return Round($iBytes, $iRound) & $aArray[$A]
EndFunc   ;==>_ByteSuffix
; #INTERNAL_USE_ONLY#============================================================================================================

Example use of Function:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

Global $sFilePath, $sFileURL

$sFileURL = "http://ftp.opera.com/pub/opera/win/1152/en/Opera_1152_en_Setup.exe"
$sFilePath = _InetGetProgress($sFileURL, @TempDir & "\")
If @error Then
    MsgBox(64, "Error", "Check the URL or your Internet Connection!")
Else
    MsgBox(64, "Success", "Downloaded >> " & $sFilePath)
EndIf
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

And an Example using a GUI. It's slightly different to >> Also this is an example which of course can be improved upon! I hope it gives you inspiration to look into creating GUI's :x

Function:

; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
; #INDEX# =======================================================================================================================
; Title .........: _InetGetGUI
; AutoIt Version : v3.3.2.0 or higher
; Language ......: English
; Description ...: Download a file updating a GUICtrlCreateProgress.
; Note ..........:
; Author(s) .....: guinness
; Remarks .......:
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
; _InetGetGUI: Download a file updating a GUICtrlCreateProgress.
; ===============================================================================================================================

; #INTERNAL_USE_ONLY#============================================================================================================
; _ByteSuffix ......; Convert bytes to the largest measure. Thanks to Spliff69 - http://www.autoitscript.com/forum/topic/...ync-tool/page__view__findpost_
; ===============================================================================================================================

; #FUNCTION# =========================================================================================================
; Name...........: _InetGetGUI()
; Description ...: Download a file updating a GUICtrlCreateProgress().
; Syntax.........: _InetGetGUI($sURL, $iLabel, $iProgress, $iButton, [$sDirectory = @ScriptDir])
;                 $sURL - A valid URL that contains the filename too.
;                 $iLabel - ControlID of a GUICtrlCreateLabel.
;                 $iProgress - ControlID of a GUICtrlCreateProgress.
;                 $iButton - ControlID of a GUICtrlCreateButton.
;                 $sDirectory - [Optional] Directory of where to download to. Default = @ScriptDir
; Parameters ....: None
; Requirement(s).: v3.3.2.0 or higher
; Return values .: Success - Downloaded filename.
;                  Failure - Returns downloaded filename & sets @error = 1 (@extended = 0 if internal error or @extended = 1 if cancelled was selected.)
; Author ........: guinness
; Example........; Yes
;=====================================================================================================================
Func _InetGetGUI($sURL, $iLabel, $iProgress, $iButton, $sDirectory = @ScriptDir)
    Local $hDownload, $iBytesRead = 0, $iError = 0, $iFileSize, $iPercentage, $iSpeed = 0, $iTimer = 0, $sFilePath, $sProgressText, $sRead = GUICtrlRead($iButton), $sSpeed
    $sFilePath = StringRegExpReplace($sURL, "^.*/", "")
    If @error Then
        Return SetError(1, 0, $sFilePath)
    EndIf

    $sDirectory = StringRegExpReplace($sDirectory, "[\\/]+\z", "") & "\" & $sFilePath
    $iFileSize = InetGetSize($sURL, 1)
    $hDownload = InetGet($sURL, $sDirectory, 0, 1)
    If @error Then
        Return SetError(1, $iError, $sFilePath)
    EndIf
    GUICtrlSetData($iButton, "&Cancel")

    $sSpeed = "Current Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
    $iTimer = TimerInit()
    While InetGetInfo($hDownload, 2) = 0
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $iButton
                GUICtrlSetData($iLabel, "Download Cancelled!")
                $iError = 1
                ExitLoop
        EndSwitch

        $iBytesRead = InetGetInfo($hDownload, 0)
        $iPercentage = $iBytesRead * 100 / $iFileSize
        $sProgressText = "Downloading " & _ByteSuffix($iBytesRead, 0) & " Of " & _ByteSuffix($iFileSize, 0) & @LF & $sSpeed
        GUICtrlSetData($iLabel, $sProgressText)
        GUICtrlSetData($iProgress, $iPercentage)

        If TimerDiff($iTimer) > 1000 Then
            $sSpeed = "Current Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
            $iSpeed = $iBytesRead
            $iTimer = TimerInit()
        EndIf
        Sleep(100)
    WEnd
    InetClose($hDownload)
    GUICtrlSetData($iButton, $sRead)
    Return SetError($iError, $iError, $sFilePath)
EndFunc   ;==>_InetGetGUI

; #INTERNAL_USE_ONLY#============================================================================================================
Func _ByteSuffix($iBytes, $iRound = 2)
    Local $A, $aArray[9] = [" B", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"]
    While $iBytes > 1023
        $A += 1
        $iBytes /= 1024
    WEnd
    Return Round($iBytes, $iRound) & $aArray[$A]
EndFunc   ;==>_ByteSuffix
; #INTERNAL_USE_ONLY#============================================================================================================

Example use of Function:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

#include <GUIConstantsEx.au3>

_Main()

Func _Main()
    Local $sFilePathURL = "http://ftp.opera.com/pub/opera/win/1152/en/Opera_1152_en_Setup.exe"
    Local $hGUI, $iButton, $iLabel, $iProgressBar, $sFilePath

    $hGUI = GUICreate("_InetGetGUI()", 370, 90, -1, -1)
    $iLabel = GUICtrlCreateLabel("Welcome to the simple Downloader!", 5, 5, 270, 40)
    $iButton = GUICtrlCreateButton("&Download", 275, 2.5, 90, 25)
    $iProgressBar = GUICtrlCreateProgress(5, 60, 360, 20)
    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit

            Case $iButton
                $sFilePath = _InetGetGUI($sFilePathURL, $iLabel, $iProgressBar, $iButton, @ScriptDir)
                If @error Then
                    Switch @extended ; Check what the actual error was by using the @extended command.
                        Case 0
                            MsgBox(64, "Error", "Check the URL or your Internet Connection!")

                        Case 1
                            MsgBox(64, "Fail", "Seems the download was canecelled, but the file was >> " & $sFilePath)

                    EndSwitch
                Else
                    MsgBox(64, "Success", "Downloaded >> " & $sFilePath)
                EndIf

        EndSwitch
    WEnd
EndFunc   ;==>_Main
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Just a couple of tweaks to the above examples, I haven't added too much because obviously you can change how you wish the Functions etc to work.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • 7 months later...

It's my code that i used some times ago to download a file with progress bar, also you can see that it check a file on the internet for updates using iniread. i hope can help.

#NoTrayIcon
#include <Constants.au3>

Dim $Download
Dim $FileName

;~ --------------------------------------------------

;~ Get Download Info
$GetInfo = InetGet("http://garena.godlike-exp.ir/info.dat", @TempDir & "\info.dat", 1, 1)

Do
Until InetGetInfo($GetInfo, 2)

InetClose($GetInfo)

$Version = IniRead(@TempDir & "\info.dat", "GoDLiKe.eXp", "Version", "Can't read file.")
$URL = IniRead(@TempDir & "\info.dat", "GoDLiKe.eXp", "URL", "Can't read file.")
$FileSize = IniRead(@TempDir & "\info.dat", "GoDLiKe.eXp", "File Size", "Can't read file.")
$ReleaseData = IniRead(@TempDir & "\info.dat", "GoDLiKe.eXp", "Release Data", "Can't read file.")
$FileName = IniRead(@TempDir & "\info.dat", "GoDLiKe.eXp", "File Name", "Can't read file.")

FileDelete(@TempDir & "\info.dat")

If $Version = 5.3 OR $Version > 5.3 Then
    Exit
EndIf
;~ --------------------------------------------------

;~ Ask User for Download
$Info = "Latest Version: " & $Version & @LF & "Release Date: " & $ReleaseData & @LF & "File Size: " & $FileSize & " KB" & @LF & @LF & "Do you want to download now?"
$What = MsgBox(4, "GoDLiKe.eXp Auto Updater", $Info)
If $What = 7 Then
    Exit
EndIf

;~ --------------------------------------------------

;~ Show Progress
ProgressOn("GoDLiKe.eXp Updater", "", "Please Wait...", -1, -1, "16")

;~ Start Download
$Download = InetGet($URL, $FileName, 1, 1)

;~ Downloding & Progress Bar
Do
    $Downloaded_B = InetGetInfo($Download, 0)
    $Downloaded_KB = Round($Downloaded_B / 1024)

    $Percent = Round($Downloaded_KB / $FileSize * 100)

    $Status = $Downloaded_KB & " KB of " & $FileSize & " KB" & @LF & $Percent & "%" & " Downloaded."

    ProgressSet($Percent, $Status, "Press Ctrl + Alt + Q to Exit.")

    Sleep(100)

Until InetGetInfo($Download, 2)

InetClose($Download)

ProgressOff() ;Download Completed.

;~ --------------------------------------------------

;~ Show MsgBox
$FinishMsg = MsgBox(36, "GoDLiKe.eXp", "Download Completed." & @LF & "Do you to install GoDLiKe.eXp " & $Version & " now?")
If $FinishMsg = 6 Then
    ShellExecute($FileName)
    Exit
EndIf
Link to comment
Share on other sites

  • 3 months later...

@guinness, I have a question.

I've been working on a program and this works wonderfully, just one thing I gotta ask: how can I have it change the name of the file it downloads to something more standard? like say the file it downloads is "testfile121011.exe" and I want it to be just "testfile.exe". I know I could pass a FileCopy() and have it change it afterwards and delete the original but I'd rather just have it do it like the code can without a progressbar. Since I'm not sure how to pass that to your function, any help would be awesome :D

Link to comment
Share on other sites

Look at the $sFilePath parameter, I just added it to the _InetGetGUI UDF.

; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
; #INDEX# =======================================================================================================================
; Title .........: _InetGetGUI
; AutoIt Version : v3.3.2.0 or higher
; Language ......: English
; Description ...: Download a file updating a GUICtrlCreateProgress.
; Note ..........:
; Author(s) .....: guinness
; Remarks .......:
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
; _InetGetGUI: Download a file updating a GUICtrlCreateProgress.
; ===============================================================================================================================

; #INTERNAL_USE_ONLY#============================================================================================================
; _ByteSuffix ......; Convert bytes to the largest measure. Thanks to Spliff69 - http://www.autoitscript.com/forum/topic/...ync-tool/page__view__findpost_
; ===============================================================================================================================

; #FUNCTION# =========================================================================================================
; Name...........: _InetGetGUI()
; Description ...: Download a file updating a GUICtrlCreateProgress().
; Syntax.........: _InetGetGUI($sURL, $iLabel, $iProgress, $iButton, [$sDirectory = @ScriptDir, [$sFilePath = -1]])
; $sURL - A valid URL that contains the filename too.
; $iLabel - ControlID of a GUICtrlCreateLabel.
; $iProgress - ControlID of a GUICtrlCreateProgress.
; $iButton - ControlID of a GUICtrlCreateButton.
; $sDirectory - [Optional] Directory of where to download to. Default = @ScriptDir
; $sFilePath - [Optional] FilePath to be used. Default = FileName of the original download.
; Parameters ....: None
; Requirement(s).: v3.3.2.0 or higher
; Return values .: Success - Downloaded filename.
; Failure - Returns downloaded filename & sets @error = 1 (@extended = 0 if internal error or @extended = 1 if cancelled was selected.)
; Author ........: guinness
; Example........; Yes
;=====================================================================================================================
Func _InetGetGUI($sURL, $iLabel, $iProgress, $iButton, $sDirectory = @ScriptDir, $sFilePath = -1)
    Local $hDownload, $iBytesRead = 0, $iError = 0, $iFileSize, $iPercentage, $iSpeed = 0, $iTimer = 0, $sProgressText, $sRead = GUICtrlRead($iButton), $sSpeed

    If $sFilePath = -1 Then
        $sFilePath = StringRegExpReplace($sURL, "^.*/", "")
        If @error Then
            Return SetError(1, 0, $sFilePath)
        EndIf
    EndIf

    $sDirectory = StringRegExpReplace($sDirectory, "[/]+z", "") & "" & $sFilePath
    $iFileSize = InetGetSize($sURL, 1)
    $hDownload = InetGet($sURL, $sDirectory, 0, 1)
    If @error Then
        Return SetError(1, $iError, $sFilePath)
    EndIf
    GUICtrlSetData($iButton, "&Cancel")

    $sSpeed = "Current Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
    $iTimer = TimerInit()
    While InetGetInfo($hDownload, 2) = 0
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $iButton
                GUICtrlSetData($iLabel, "Download Cancelled!")
                $iError = 1
                ExitLoop
        EndSwitch

        $iBytesRead = InetGetInfo($hDownload, 0)
        $iPercentage = $iBytesRead * 100 / $iFileSize
        $sProgressText = "Downloading " & _ByteSuffix($iBytesRead, 0) & " Of " & _ByteSuffix($iFileSize, 0) & @LF & $sSpeed
        GUICtrlSetData($iLabel, $sProgressText)
        GUICtrlSetData($iProgress, $iPercentage)

        If TimerDiff($iTimer) > 1000 Then
            $sSpeed = "Current Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
            $iSpeed = $iBytesRead
            $iTimer = TimerInit()
        EndIf
        Sleep(100)
    WEnd
    InetClose($hDownload)
    GUICtrlSetData($iButton, $sRead)
    Return SetError($iError, $iError, $sFilePath)
EndFunc   ;==>_InetGetGUI

; #INTERNAL_USE_ONLY#============================================================================================================
Func _ByteSuffix($iBytes, $iRound = 2)
    Local $A, $aArray[9] = [" B", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"]
    While $iBytes > 1023
        $A += 1
        $iBytes /= 1024
    WEnd
    Return Round($iBytes, $iRound) & $aArray[$A]
EndFunc   ;==>_ByteSuffix
; #INTERNAL_USE_ONLY#============================================================================================================
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

That actually gave me a bunch of errors, and not only that, I found a temporary method that will work in the non GUI version:

;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
; #INDEX# =======================================================================================================================
; Title .........: _InetGetProgress
; AutoIt Version : v3.3.2.0 or higher
; Language ......: English
; Description ...: Download a file showing a progress bar using ProgressOn.
; Note ..........:
; Author(s) .....: guinness
; Remarks .......:
; ===============================================================================================================================
; #CURRENT# =====================================================================================================================
; _InetGetProgress: Download a file showing a progress bar using ProgressOn.
; ===============================================================================================================================
; #INTERNAL_USE_ONLY#============================================================================================================
; _ByteSuffix ......; Convert bytes to the largest measure. Thanks to Spliff69 - http://www.autoitscript.com/forum/topic/...ync-tool/page__view__findpost_
; ===============================================================================================================================
; #FUNCTION# =========================================================================================================
; Name...........: _InetGetProgress()
; Description ...: Download a file showing a progress bar using ProgressOn.
; Syntax.........: _InetGetProgress($sURL, [$sDirectory = @ScriptDir])
;                $sURL - A valid URL that contains the filename too.
;                $sDirectory - [Optional] Directory of where to download to @ScriptDir
; Parameters ....: None
; Requirement(s).: v3.3.2.0 or higher
; Return values .: Success - Downloaded filename.
;                 Failure - Returns downloaded filename & sets @error = 1
; Author ........: guinness
; Example........; Yes
;=====================================================================================================================
Func _InetGetProgress($sURL, $sDirectory = @ScriptDir)
    Local $hDownload, $iBytesRead = 0, $iFileSize, $iPercentage, $iSpeed = 0, $iTimer = 0, $sFilePath, $sProgressText, $sSpeed
    $sFilePath = StringRegExpReplace($sURL, "^.*/", "")
    If @error Then
        Return SetError(1, 0, $sFilePath)
    EndIf
$sFilePath = InputBox("Need filename please.","Please enter the filename desired.","")
    $sDirectory = StringRegExpReplace($sDirectory, "[\\/]+\z", "") & "\" & $sFilePath
    $iFileSize = InetGetSize($sURL, 1)
    $hDownload = InetGet($sURL, $sDirectory, 0, 1)
    If @error Then
        Return SetError(1, 0, $sFilePath)
    EndIf
    ProgressOn("", "")
    $sSpeed = "Current Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
    $iTimer = TimerInit()
    While InetGetInfo($hDownload, 2) = 0
        $iBytesRead = InetGetInfo($hDownload, 0)
        $iPercentage = $iBytesRead * 100 / $iFileSize
        $sProgressText = "Downloading " & _ByteSuffix($iBytesRead, 0) & " Of " & _ByteSuffix($iFileSize, 0) & @LF & $sSpeed
        ProgressSet(Round($iPercentage, 0), $sProgressText, "Downloading: " & $sFilePath)
        If TimerDiff($iTimer) > 1000 Then
            $sSpeed = "Current Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
            $iSpeed = $iBytesRead
            $iTimer = TimerInit()
        EndIf
        Sleep(100)
    WEnd
    InetClose($hDownload)
    ProgressOff()
    Return $sFilePath
EndFunc   ;==>_InetGetProgress
; #INTERNAL_USE_ONLY#============================================================================================================
Func _ByteSuffix($iBytes, $iRound = 2)
    Local $A, $aArray[9] = [" B", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"]
    While $iBytes > 1023
        $A += 1
        $iBytes /= 1024
    WEnd
    Return Round($iBytes, $iRound) & $aArray[$A]
EndFunc   ;==>_ByteSuffix
; #INTERNAL_USE_ONLY#============================================================================================================

I took $sFilePath and I presently have it ask me for the name I wish to give the file. Still trying to mesh out the having it auto assigned without remaking the function for every download. I do appreciate the work you've done :D

Link to comment
Share on other sites

Updated the UDF in the last post. You didn't really mention which UDF you were using so I presumed by what you wrote that you meant the GUI version & secondly when you say errors it's a little hard to know what exactly.

It appears you have knowledge of AutoIt so it shouldn't be hard for you to modify the UDF to suit your needs.

Edit: Just saw the InputBox, not something I would do in a Function per say.

Here's how I would do it for the ProgressOn version.

; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
; #INDEX# =======================================================================================================================
; Title .........: _InetGetProgress
; AutoIt Version : v3.3.2.0 or higher
; Language ......: English
; Description ...: Download a file showing a progress bar using ProgressOn.
; Note ..........:
; Author(s) .....: guinness
; Remarks .......:
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
; _InetGetProgress: Download a file showing a progress bar using ProgressOn.
; ===============================================================================================================================

; #INTERNAL_USE_ONLY#============================================================================================================
; _ByteSuffix ......; Convert bytes to the largest measure. Thanks to Spliff69 - http://www.autoitscript.com/forum/topic/...ync-tool/page__view__findpost_
; ===============================================================================================================================

; #FUNCTION# =========================================================================================================
; Name...........: _InetGetProgress()
; Description ...: Download a file showing a progress bar using ProgressOn.
; Syntax.........: _InetGetProgress($sURL, [$sDirectory = @ScriptDir, [$sFilePath = -1]])
;                 $sURL - A valid URL that contains the filename too.
;                 $sDirectory - [Optional] Directory of where to download to @ScriptDir
;                 $sFilePath - [Optional] FilePath to be used. Default = FileName of the original download.
; Parameters ....: None
; Requirement(s).: v3.3.2.0 or higher
; Return values .: Success - Downloaded filename.
;                  Failure - Returns downloaded filename & sets @error = 1
; Author ........: guinness
; Example........; Yes
;=====================================================================================================================
Func _InetGetProgress($sURL, $sDirectory = @ScriptDir, $sFilePath = -1)
    Local $hDownload, $iBytesRead = 0, $iFileSize, $iPercentage, $iSpeed = 0, $iTimer = 0, $sProgressText, $sSpeed
    If $sFilePath = -1 Then
        $sFilePath = StringRegExpReplace($sURL, "^.*/", "")
        If @error Then
            Return SetError(1, 0, $sFilePath)
        EndIf
    EndIf

    $sDirectory = StringRegExpReplace($sDirectory, "[/]+z", "") & "" & $sFilePath
    $iFileSize = InetGetSize($sURL, 1)
    $hDownload = InetGet($sURL, $sDirectory, 0, 1)
    If @error Then
        Return SetError(1, 0, $sFilePath)
    EndIf
    ProgressOn("", "")

    $sSpeed = "Current Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
    $iTimer = TimerInit()
    While InetGetInfo($hDownload, 2) = 0
        $iBytesRead = InetGetInfo($hDownload, 0)
        $iPercentage = $iBytesRead * 100 / $iFileSize
        $sProgressText = "Downloading " & _ByteSuffix($iBytesRead, 0) & " Of " & _ByteSuffix($iFileSize, 0) & @LF & $sSpeed
        ProgressSet(Round($iPercentage, 0), $sProgressText, "Downloading: " & $sFilePath)

        If TimerDiff($iTimer) > 1000 Then
            $sSpeed = "Current Speed: " & _ByteSuffix($iBytesRead - $iSpeed) & "/s"
            $iSpeed = $iBytesRead
            $iTimer = TimerInit()
        EndIf
        Sleep(100)
    WEnd
    InetClose($hDownload)
    ProgressOff()
    Return $sFilePath
EndFunc   ;==>_InetGetProgress

; #INTERNAL_USE_ONLY#============================================================================================================
Func _ByteSuffix($iBytes, $iRound = 2)
    Local $A, $aArray[9] = [" B", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"]
    While $iBytes > 1023
        $A += 1
        $iBytes /= 1024
    WEnd
    Return Round($iBytes, $iRound) & $aArray[$A]
EndFunc   ;==>_ByteSuffix
; #INTERNAL_USE_ONLY#============================================================================================================
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Oops sorry lol. A little out of practice when it comes to helping debugging.

It complained in the GUI version you updated that it was missing a WEnd and when added it then said missing EndSwitch. After figuring it out it starts the GUI but fails to download.

Edit: Yeah I was using that to help figure out where in the code did it need to grab the final name of the file. Was working on a way to pass that from the main branch of code into the function.

Edited by hackersarchangel
Link to comment
Share on other sites

I just tried the _InetGetGUI I gave you with the example of downloading Opera and it works perfectly. I'm using the latest beta of AutoIt and Windows 7 x64. What are you using?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Not the beta lol using the newest non Beta. Windows 7 x64. And after adding the requested bits from the compiler, and just tweaking the box text, I tried it and it just sat there. Should I be running the beta??

ROFL I just noticed a minor error on my part. One second.

Edited by hackersarchangel
Link to comment
Share on other sites

By 'non beta' I take it you mean V3.3.6.1? As you can see from #post16 I updated the UDF _InetGetProgress to allow you to pass the filname e.g.

_InetGetProgress("http://example.com/randomfile1234.txt", @ScriptDir, "RandomFile.txt")
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...