Jump to content
Sign in to follow this  

how to pause and resume the download in InetGet function

Recommended Posts


Can we pause and resume the download in the InetGet function?
If is possible, what is the solution please?
I used this code To manage the download

#include <INet.au3>
func _downloader($name, $linc, $filepath, $RTLF = false, $link = false)
    global $downloader = GUICreate("downloader", 400, 200, -1, -1, $WS_CLIPCHILDREn, $RTLF, $link)
    global $path = $filePath
$labelTxt = GUICtrlCreateLabel("downloading " & $name, 50, 10, 200, 20)
global $labelTxt0 = GUICtrlCreateLabel("downloaded size 0 MB " & "OF 0 MB", 50, 60, 300, 20)
global $Progress = ""
global $sText = ""
    For $i = 1 To Random(5, 20, 1) ; Return an integer between 5 and 20 to determine the length of the string.
        $sText &= Chr(Random(65, 122, 1)) ; Return an integer between 65 and 122 which represent the ASCII characters between a (lower-case) to Z (upper-case).
global $labelTxt2 = GUICtrlCreateInput("0%", 50, 80, 50, 20)
_GUICtrlEdit_SetReadOnly(-1, true)
global $beep = GUICtrlCreateCheckBox("use the progress beep notification", 150, 120, 200, 20)
$button = GUICtrlCreateButton("Cancel', 130, 150, 180, 25, 0x01)
$iIndex = 0
global $Target
global $url
global $Progress = GUICtrlCreateProgress(50, 90, 150, 20)
global $Target = $filepath
global $url = $linc
global $path = $filepath
global $hDownloadNo = _RSMWare_GetData($url, $Target)
global $status = false
global $onprogress = false, $curent = false
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $button
$asc = MsgBox(4132,"exit download?","if you click yes the downloading will be cancel, do you want to cancel it ?")
if $asc = 6 then
    If $hDownloadNo <> 0 Then InetClose($hDownloadNo)
if $status = -1 then
$status = 0
$hDownloadNo = _RSMWare_GetData($url, $Target)
$onprogress = false
$curent = false
elseIf $Status = 1 then
$status = $path
return $status
Func _RSMWare_GetData($url, $Target)
Local $hDownload = InetGet($url, $Target, 1, 1)
Return $hDownload
EndFunc ;==>_RSMWare_GetData
    Func SetProgress()
Local $state
If $hDownloadNo <> 0 Then
$state = InetGetInfo($hDownloadNo)
If @error = 0 Then
$infor = "downloaded size " & Round(Execute(InetGetInfo($hDownloadNo, $INET_DOWNLOADREAD) / 1048576), 2) & " MB of " & Round(Execute(InetGetInfo($hDownloadNo, $INET_DOWNLOADSIZE) / 1048576), 2) & " MB "
$onprogress = Round(Ceiling(($state[0] / $state[1]) * 100))
if not (InetGetInfo($hDownloadNo, $INET_DOWNLOADSIZE) = 0) then
if $onProgress <= 0 then $onProgress = 0
GUICtrlSetData($Progress, $onProgress)
GUICtrlSetData($labelTxt0, $infor)
GUICtrlSetData($labelTxt2, $onProgress & "%")
if _isChecked($beep) then
if $onprogress > $curent then
beep((100 + $onprogress * 20), 100)
$curent = $onprogress
If $state[2] Then
If $state[3] Then
$status = 1
$status = -1
EndFunc ;==>SetProgress

Share this post

Link to post
Share on other sites

You can only stop it and do it again.

Share this post

Link to post
Share on other sites

Is there another way to download files, Enable us to pause and resume the download?

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
Sign in to follow this  

  • Similar Content

    • BogdanNicolescu
      By BogdanNicolescu
      While 1 / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / WEnd OR:

      HotKeySet("{ESC}", "Terminate") While 1 MouseClick("Right",674,422) MouseClick("Left",673,447) Sleep(2000) / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / MouseClick("Left",675,339) SLeep(3000) WEnd Func Terminate()     Exit 0 EndFunc  
      Sorry if i should't let this here to be found by newbies like me -.-'
    • santoshM
      By santoshM
      Dear friends i am facing a problem , i have created a window in autoit some time it is moving with the mouse curser even if iam not clicking the window 
    • sumanth1980
      By sumanth1980
      Here i am wrote a simple lines to install basic applications but when i clicked on one application/program to install it was working fine but when i cancel the program in the middle to install another program it was not working. I am not an expert in this but i want a solution for this ... Can any one help me on this....
    • PleaseHelpMEIWillLoveyou
      By PleaseHelpMEIWillLoveyou
      Is there a way to use a custom terminal or something from my pc and run a script on another pc.
      please let me know if its possible
      (not for anything bad just for a project im working on)
    • juniq
      By juniq
      Hey I'm writing on a script which places a link in the context menu so you can choose several mp3 files and rename them using id3 tag udf and year / time stuff variables.
      My problem: I'm renaming the files through "FileMove", But HOW can I get the current directory of the chosen files only? I can't use stringsplit cz there are more than 1 delimiter "\". and I can't trim the string because the stringlength changes every time. How can I get ONLY the directory where the files from $cmdline chosen are?