CODICE
$timer = TimerInit()
$sec = 0
$min = 0
;Carica il percorso della cartella
$path = RegRead("HKEY_CURRENT_USER\Software\DownloadM\", "path")
if @error =0 Then
$str = StringSplit($path, '\') ;Cerca un "/"
while ($str[0]=1) ;continua finchè non trova un "\"
$path= FileSelectFolder("Seleziona la cartella dei tuoi download","",1, "")
if @error=1 Then ;se clicca su annulla
$return = msgbox(4,"Impostazioni obbligaorie","La cartella attualmente non è impostata è impossibile quindi proseguire, vuoi uscire ?")
if $return=6 then Exit ; 6 = YES
EndIf
$str = StringSplit($path, '\') ; assegna a str il valore della ricerca di "\"
wend
;Se è tutto ok salva il percorso della cartella
$success = RegWrite("HKEY_CURRENT_USER\Software\DownloadM", "path", "REG_SZ", $path)
if $success="" Then
TrayTip("DownloadM","Cartella non salvata errore " & @error,10,3)
Else
TrayTip("DownloadM","Cartella impostata correttamente",10,1)
sleep(2500)
EndIf
Else
RegWrite("HKEY_CURRENT_USER\Software\DownloadM", "path", "REG_SZ", "")
TrayTip("DownloadM","Percorso cartella non caricato,Riparazione in corso...Uscita dal programma" ,10,3)
EndIf
$val_tmr = RegRead("HKEY_CURRENT_USER\Software\DownloadM\", "time")
if @error =0 Then
if $val_tmr="" then
TrayTip("DownloadM","Parametro errato . Impostato a 60s come default",20,2)
$val_tmr=60 ; Valore di default
RegWrite("HKEY_CURRENT_USER\Software\DownloadM", "Time", "REG_SZ", $val_tmr)
Else
TrayTip("DownloadM","Caricato parametro Time="& $val_tmr,20,1)
EndIf
Else
TrayTip("DownloadM","Errore parametro Time,settato a 60s come default" ,10,3)
$val_tmr=60 ; Valore di default
RegWrite("HKEY_CURRENT_USER\Software\DownloadM", "Time", "REG_SZ", $val_tmr)
EndIf
$Error = FileChangeDir ( $path ) ;si sposta sulla cartella di lavoro
if $Error =0 then
TrayTip("DownloadM","Impossibile settare il percorso..Continua",15,3)
EndIf
Opt("TrayAutoPause",0) ; Script Paused/exit visibili, script in run
$configura = TrayCreateMenu("Configura") ; creazione di un menù sul system tray
$dir = TrayCreateItem("Cartelle", $configura)
$cont = TrayCreateItem("Imposta tempo", $configura)
TrayCreateItem("")
$www = TrayCreateMenu("www")
$displayitem = TrayCreateItem("http://www.autoit.forumcommunity.net/", $www)
while 1
TraySetToolTip("Time: " & $min & " min" & $sec & " sec")
$search = FileFindFirstFile("*.*")
If $search = -1 Then
MsgBox(0, "Error", "Non ci sono files nella cartella")
Exit
EndIf
$menu = TrayGetMsg()
if $menu = $dir then
$pathtmp = FileSelectFolder("Seleziona la cartella dei tuoi download", "")
$Error = FileChangeDir ( $pathtmp )
if $Error =0 then
TrayTip("DownloadM","Percorso errato",20,2)
Else
RegWrite("HKEY_CURRENT_USER\Software\DownloadM\", "path", "REG_SZ", $pathtmp)
$path=$pathtmp
TrayTip("DownloadM","Cartella impostata correttamente",10,1)
EndIf
EndIf
if $menu = $cont then
$val_tmr = InputBox ("Ogni tot minuti DownloadM aggiornerà la cartella utente", "Quanti minuti (max 60)","","",150,150)
if $val_tmr >60 or $val_tmr = 0 then
TrayTip("DownloadM","Parametro errato ,(da 1 a 60)",20,2)
Else
TrayTip("DownloadM","Tempo=" & $val_tmr & "minuto",10,1)
RegWrite("HKEY_CURRENT_USER\Software\DownloadM", "Time", "REG_SZ", $val_tmr)
EndIf
EndIf
if $menu = $www Then ShellExecute("http://autoit.forumcommunity.net/")
if TimerDiff($timer) > 999 Then
$sec += 1
$timer = TimerInit()
EndIf
if $sec = 60 Then
$min += 1
$sec = 0
EndIf
if $min = $val_tmr Then ;temporizzatore
$min =0
TraySetState(4)
while 1
$file = FileFindNextFile($search)
If @error Then
sleep(3000)
ExitLoop
EndIf
$array = StringSplit($file, '.')
$max = ubound ($array,1)
;per il file senza estensione non crea cartella
if ($max-1)>0 then
DirCreate($array[$max-1])
If FileExists($path & "\*."& $array[$max-1]) Then filemove($path & "\*." & $array[$max-1],$path & "\" & $array[$max-1],1)
EndIf
WEnd
TraySetState(8)
EndIf
WEnd