Download Manager

« Older   Newer »
  Share  
Matrix33
CAT_IMG Posted on 18/6/2008, 10:39     +1   -1




Eccovi qui un piccolo programma di download fatto da me che sono alle prime armi
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

commenti, critiche e quant'altro sono ben accetti :)
ps ringrazio matteojug per avermi aiutato con la barra di progresso ;)

Edited by Matrix33 - 18/6/2008, 14:11

Download attachment
Download_Manager.rar ( Number of downloads: 12 )

 
Top
lknokl
CAT_IMG Posted on 18/6/2008, 10:48     +1   -1




Mi da errore ^^

(104,1) : ERROR: missing EndSwitch.
Func
^
(29,20) : REF: missing EndSwitch.
Switch $nMsg
~~~~~~~~~~~~~~~~~~~^
(104,1) : ERROR: missing Wend.
Func
^(27,1) : REF: missing Wend.
While
^
(110,1) : ERROR: syntax error
EndSwitch
^
- 3 error(s), 0 warning(s)
 
Top
Matrix33
CAT_IMG Posted on 18/6/2008, 10:52     +1   -1




strano, ho appena copiato il codice da questa pagina in un documento nuovo di autoit v3 e funziona bene... nn saprei dirti il perchè
 
Top
lknokl
CAT_IMG Posted on 18/6/2008, 11:06     +1   -1




ho riprovato ancora :( proprio quando trovo qualcosa che mi e utile :(
 
Top
Matrix33
CAT_IMG Posted on 18/6/2008, 11:11     +1   -1




umm strano, magari appena viene qualcuno lo prova anche lui e vediamo se da anke errore
nel frattempo ho postato l'eseguibile nel primo post
 
Top
MatteoJug
CAT_IMG Posted on 18/6/2008, 11:44     +1   -1




Pure a me mi dava quell'errore, però non è un errore, e un lettura errata del codice, per risolverla basta spostare dal ciclo la funzione _Uscita() e metterla alla fine, dopo il ciclo...
 
Top
Matrix33
CAT_IMG Posted on 18/6/2008, 12:51     +1   -1




allora così dovrebbe andare, perchè a me va
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

 
Top
lknokl
CAT_IMG Posted on 18/6/2008, 13:08     +1   -1




Molto bello ^^ ora funziona
 
Top
Matrix33
CAT_IMG Posted on 18/6/2008, 13:11     +1   -1




grazie :)
 
Top
8 replies since 18/6/2008, 10:39   171 views
  Share