Local $Form1 = GUICreate("Form1", 638, 200, 192, 124)
Local $Label1 = GUICtrlCreateLabel("Ссылка на файл", 32, 16, 260, 17)
Global $Input1 = GUICtrlCreateInput("https://dl.dropboxusercontent.com/u/76571694/Best_Fiends_v3.2.2.apk", 32, 48, 569, 21)
Local $Label2 = GUICtrlCreateLabel("Скорость загрузки", 32, 120, 260, 17)
Global $Label3 = GUICtrlCreateLabel("", 32, 160, 260, 17)
Local $Button1 = GUICtrlCreateButton("Старт", 250, 152, 75, 25)
Global $Button2 = GUICtrlCreateButton("Стоп", 450, 152, 75, 25)
GUICtrlSetState(-1, 128)
Global $Progress1 = GUICtrlCreateProgress(32, 88, 566, 17)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
GUICtrlSetState($Button2, 64)
GUICtrlSetState($Button1, 128)
_FDL()
GUICtrlSetState($Button1, 64)
GUICtrlSetState($Button2, 128)
EndSwitch
WEnd
Func _FDL()
Local $Url = StringStripWS(GUICtrlRead($Input1), 3)
If $Url = '' Then Return
Local $NF = StringRegExpReplace($Url, '.*/', '')
Local $rfurl, $pfod, $tmpp, $sec, $td, $sp, $shsp, $tld
Global $ExitFunc = 0
Local $inget = InetGet($Url, @ScriptDir & '\' & $NF, 1, 1)
Local $ts = TimerInit()
GUIRegisterMsg(0x0111, 'WM_COMMAND')
While 1
If $ExitFunc Then ExitLoop
$rfurl = InetGetInfo($inget)
If Not @error Then
If Number($rfurl[4]) Then ExitLoop
EndIf
If Not Number($rfurl[0]) Then ContinueLoop
If $rfurl[2] Then
GUICtrlSetData($Progress1, 100)
ExitLoop
EndIf
If $tld < $rfurl[0] Then
$td = Int(TimerDiff($ts))
$sec = StringTrimRight($td, 3)
$sp = $rfurl[0] / $sec
$shsp = _FO_ShortFileSize($sp)
GUICtrlSetData($Label3, $shsp & ' \s');скорость загрузки - байты в секунду(это не скорость соединения)
$tld = $rfurl[0]
EndIf
$pfod = Floor($rfurl[0] / 0 * 100)
If $tmpp < $pfod Then
GUICtrlSetData($Progress1, $pfod)
$tmpp = $pfod
EndIf
WEnd
GUIRegisterMsg(0x0111, '')
GUICtrlSetData($Label3, '')
GUICtrlSetData($Progress1, '')
InetClose($inget)
EndFunc ;==>_FDL
Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0xFFFF)
Switch $nNotifyCode
Case 0
Switch $nID
Case $Button2
$ExitFunc = 1
EndSwitch
EndSwitch
Return 'GUI_RUNDEFMSG'
EndFunc ;==>WM_COMMAND
Func _FO_ShortFileSize($iBytes); Автор ..........: AZJIO
Switch $iBytes
Case 10995116277760 To 109951162777600 ; 10 - 100 TB
$iBytes = Round($iBytes / 1099511627776, 1) & ' TB'
Case 1000000000000 To 10995116277759 ; 1000 GB - 10 TB
$iBytes = Round($iBytes / 1099511627776, 2) & ' TB'
Case 107374182400 To 999999999999 ; 100 - 999 GB
$iBytes = Round($iBytes / 1073741824) & ' GB'
Case 10737418240 To 107374182399 ; 10 - 100 GB
$iBytes = Round($iBytes / 1073741824, 1) & ' GB'
Case 1000000000 To 10737418239 ; 1000 MB - 10 GB
$iBytes = Round($iBytes / 1073741824, 2) & ' GB'
Case 104857600 To 999999999 ; 100 - 999 MB
$iBytes = Round($iBytes / 1048576) & ' MB'
Case 10485760 To 104857599 ; 10 - 100 MB
$iBytes = Round($iBytes / 1048576, 1) & ' MB'
Case 1000000 To 10485759 ; 1000 KB - 10 MB
$iBytes = Round($iBytes / 1048576, 2) & ' MB'
Case 102400 To 999999 ; 100 - 999 KB
$iBytes = Round($iBytes / 1024) & ' KB'
Case 10240 To 102399 ; 10 - 100 KB
$iBytes = Round($iBytes / 1024, 1) & ' KB'
Case 1000 To 10239 ; 1000 B - 10 KB
$iBytes = Round($iBytes / 1024, 2) & ' KB'
Case 0 To 999
$iBytes &= ' B'
EndSwitch
Return $iBytes
EndFunc ;==>_FO_ShortFileSize