CODICE
#include <guiconstants.au3>
#NoTrayIcon
$Download=False
$Form=GUICreate("Download Manager",400,240)
GUICtrlCreateLabel("Inserisci il link del file da scaricare",5,5,390,15)
$Indirizzo=GUICtrlCreateInput("",5,25,345,20)
$Clip=GUICtrlCreateButton("Incolla",355,25,40,20)
GUICtrlCreateLabel("Inserisci il percorso su cui salvare il file",5,50,390,15)
$Path=GUICtrlCreateInput(@DesktopDir&"\",5,70,335,20)
$SeleCart=GUICtrlCreateButton("Sfoglia...",345,70,50,20)
GUICtrlCreateLabel("Inserisci il nome del file da salvare con estensione",5,95,390,15)
$FileName=GUICtrlCreateInput("",5,115,345,20)
$ButSplit=GUICtrlCreateButton("Split",355,115,40,20)
$Size=GUICtrlCreateLabel("",5,145,200,20)
$ButDown=GUICtrlCreateButton("Download",5,165,80,20)
$ButAbort=GUICtrlCreateButton("Stop",90,165,80,20)
$FileSize=GUICtrlCreateButton("Verifica dimensione",190,165,100,20)
$ButAzzeraAll=GUICtrlCreateButton("Azzera tutto",295,165,100,20)
$ByteRicevuti=GUICtrlCreateLabel("",5,195,390,20)
$Progress=GUICtrlCreateProgress(5,215,335,20)
$Esci=GUICtrlCreateButton("Esci",345,215,50,20)
GUISetState (@SW_SHOW)
While 1
$nMsg=GUIGetMsg()
Switch $nMsg
Case $ButDown
If GUICtrlRead($Indirizzo)="" Or GUICtrlRead($Path)="" Or GUICtrlRead($FileName)="" Then
MsgBox(48,"Errore","Non hai ancora inserito i dati")
$Download=False
Else
$Percorso=GUICtrlRead($Path)
$IndirizzoI=GUICtrlRead($Indirizzo)
$NomeFile=GUICtrlRead($FileName)
InetGet($IndirizzoI,$Percorso&$NomeFile,"",1)
$Spazio=InetGetSize($IndirizzoI)
GUICtrlSetData($Size,"Dimensione File "&Int($Spazio/1024) & " KBytes")
$Download=True
EndIf
Case $FileSize
If GUICtrlRead($Indirizzo)="" Then
MsgBox(48,"Errore","Non hai inserito nessun indirizzo")
GUICtrlSetData($Size,"")
Else
$SpazioFile=GUICtrlRead($Indirizzo)
$Spazio=InetGetSize($SpazioFile)
GUICtrlSetData($Size,"Dimensione File "&Int($Spazio/1024) & " KBytes")
EndIf
Case $SeleCart
$Folder=FileSelectFolder("Seleziona cartella in cui salvare il file","")
If $Folder="" Then
GUICtrlSetData($Path,@DesktopDir&"\")
Else
$Dir=StringSplit($Folder,"\")
$Controller=GUICtrlSetData($Path,$Dir[$Dir[0]])
GUICtrlRead($Controller)
If $Controller="" Then
GUICtrlSetData($Path,$Folder)
Else
GUICtrlSetData($Path,$Folder&"\")
EndIf
EndIf
Case $ButAbort
$Risp2=MsgBox(4,"Stop","Sei siruro di voler fermare il download?")
If $Risp2=6 Then
InetGet("Abort")
MsgBox(64,"Stop","Download fermato!")
ControlDisable("","",$ButAbort)
ControlEnable("","",$ButDown)
ControlEnable("","",$ButAzzeraAll)
ControlEnable("","",$FileSize)
ControlEnable("","",$Clip)
ControlEnable("","",$SeleCart)
ControlEnable("","",$ButSplit)
EndIf
Case $Clip
GUICtrlSetData($Indirizzo,clipget( ))
Case $ButAzzeraAll
$Risp=MsgBox(4,"Azzera tutto","Sei sicuro di voler azzerare tutti i campi?")
If $Risp=6 Then
GUICtrlSetData($Indirizzo,"")
GUICtrlSetData($Path,"")
GUICtrlSetData($FileName,"")
GUICtrlSetData($Size,"")
GUICtrlSetData($ByteRicevuti,"")
GUICtrlSetData($Progress,"")
EndIf
Case $ButSplit
$Contr=GUICtrlRead($Indirizzo)
If $Contr="" Then
MsgBox(48,"Errore","Non hai inserito nessun indirizzo")
Else
$Line=GUICtrlRead($Indirizzo)
$Split=StringSplit($Line,"/")
GUICtrlSetData($FileName,$Split[$Split[0]])
EndIf
Case $GUI_EVENT_CLOSE
_Uscita()
Case $Esci
_Uscita()
EndSwitch
If @InetGetActive=True Then
$1=GUICtrlRead($Size)
$Avanzamento=Int(@InetGetBytesRead/$Spazio*10000)/100
GUICtrlSetData($ByteRicevuti,"Ricevuti "&int(@InetGetBytesRead/1024) & " KBytes su " & $1 & " (" & $Avanzamento & "%)")
GUICtrlSetData($Progress,Int(@InetGetBytesRead/$Spazio*100))
ControlDisable("","",$ButDown)
ControlEnable("","",$ButAbort)
ControlDisable("","",$ButAzzeraAll)
ControlDisable("","",$FileSize)
ControlDisable("","",$Clip)
ControlDisable("","",$SeleCart)
ControlDisable("","",$ButSplit)
EndIf
If @InetGetActive=False Then
ControlDisable("","",$ButAbort)
EndIf
If @InetGetActive=0 And @InetGetBytesRead<>-1 And $Download=True Then
$Download=False
$GetByte=GUICtrlRead($Size)
GUICtrlSetData($ByteRicevuti,"Ricevuti " & $GetByte)
GUICtrlSetData($Progress,100)
MsgBox(64,"Completo","Download completato con successo!")
ControlEnable("","",$ButDown)
ControlEnable("","",$ButAzzeraAll)
ControlEnable("","",$FileSize)
ControlEnable("","",$Clip)
ControlEnable("","",$SeleCart)
ControlDisable("","",$ButAbort)
ControlEnable("","",$ButSplit)
EndIf
If @InetGetActive=0 And @InetGetBytesRead=-1 And $Download=True Then
$Download=False
MsgBox(64,"Errore","Si è verificato un errore mentre si tentava il download")
ControlEnable("","",$ButDown)
ControlEnable("","",$ButAzzeraAll)
ControlEnable("","",$FileSize)
ControlEnable("","",$Clip)
ControlEnable("","",$SeleCart)
ControlDisable("","",$ButAbort)
ControlEnable("","",$ButSplit)
EndIf
WEnd
Func _Uscita()
$Risp=MsgBox(4,"Esci","Sei sicuro di voler uscire?")
If $Risp=6 Then
Exit
EndIf
EndFunc