#include #include #include #include $hGUI = GUICreate("Download file", 489, 120, 190, 70) $hStatus = _GUICtrlStatusBar_Create($hGUI, -1, "", $SBARS_TOOLTIPS) Local $aParts[2] = [200, -1] _GUICtrlStatusBar_SetParts($hStatus, $aParts) _GUICtrlStatusBar_SetText($hStatus, "DL progress...",0) Local $idProgress, $hProgress $idProgress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH) $hProgress = GUICtrlGetHandle($idProgress) _GUICtrlStatusBar_EmbedControl($hStatus, 1, $hProgress) GUISetState(@SW_SHOW) Local $TotalSize, $CalBytes, $Bytes, $size $size = InetGetSize ("http://ipv4.download.thinkbroadband.com/50MB.zip") $TotalSize = Round($size / 1024) ConsoleWrite("Total size is ~" & $TotalSize & "KB" & @CRLF) Local $hDownload = InetGet("http://ipv4.download.thinkbroadband.com/50MB.zip", _ @DesktopDir & "\50MB.zip", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) Do $sec = @SEC Sleep(500) $Bytes = Round(InetGetInfo($hDownload,0)) While @SEC = $sec Sleep(800) If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd $CalBytes = Round(InetGetInfo($hDownload,0)) $TotalSize = $TotalSize - (($CalBytes - $Bytes) /1024) $Percentage = Round(($TotalSize / $size) * 100000) $Percentage = 100 - $Percentage ConsoleWrite($TotalSize & " KB of " & " / FullSize: " & $size/100 & " / " & $Percentage & "% downloaded" & @CRLF) GUICtrlSetData($hProgress, $Percentage) Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) InetClose($hDownload)