
Metal
Members-
Posts
17 -
Joined
-
Last visited
Metal's Achievements

Seeker (1/7)
0
Reputation
-
i can't get it work. I use _FFFormOptionselect("pselector", "id", 5) (i get the id by using 'web developer' firefox addon), but i get this: __FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//form[1]//select[@id='pselector']//option[position()=6]",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue.selected=true;}catch(e){'_FFXPath_Error: '+e;}; __FFRecv: _FFXPath_Error: TypeError: FFau3.WCD.evaluate("//form[1]//select[@id='pselector']//option[position()=6]", FFau3.WCD, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue is null _FFXPath ==> No match: singleNodeValue is null $sQuery: //form[1]//select[@id='pselector']//option[position()=6] - selected=true
-
Hi, i need to change value in a combo box, but i donnow how to. Can you help me please?
-
ListView get change in checking items
Metal replied to Metal's topic in AutoIt General Help and Support
ok, i think i'm understanding. To have no doubt, "somefunctionToRecordCheckBoxChange($iIndex)" is where i pass the index (0-based or 1-based?) of the clicked checkbox (the one that changed it's state) to another function i made? -
in my script i made a listview with checkboxes for each item. Now, i need to know if one of the checkboxes change it's status, how can i do? my first try was to save the starting checkboxes status, then (in gui's while1-loop) confronting actual checkboxes status with the starting-saved one, so i can catch check-status changes. But that's not so performant...
-
How can i catch a double clic on a list box item? How to know which item was double-clicked?
-
Thanks for the help. Starting from where you said, and then going back through the code, i found the problem. It was here: Func _fileListDest() ;creazione liste If FileExists(@ScriptDir & "\destd.txt") Then FileDelete(@ScriptDir & "\destd.txt") EndIf If FileExists(@ScriptDir & "\destf.txt") Then FileDelete(@ScriptDir & "\destf.txt") EndIf $filed = @ScriptDir & "\destd.txt" $filef = @ScriptDir & "\destf.txt" $info = DirGetSize($path1,1) If $info[1] = 0 AND $info[2] = 0 Then _deleteArray("info") Return 2 EndIf $fod = FileOpen($filed,2) $fof = FileOpen($filef,2) $search = _SearchFolder($path1) FileClose($fod) FileClose($fof) If $search = 1 Then;cartella non valida o inesistente [file] Return 1 ElseIf $search = 3 Then;cartella non valida o inesistente [directory] Return 3 EndIf ;lettura cartelle $read = FileRead($filed) $split = StringSplit($read,@LF) _ArrayDelete($split,$split[0]) $split[0] -= 1 For $i = 1 To $split[0] $dir1[$i] = $split[$i] Next $dir[0] = $split[0] _deleteArray("split") ;lettura file $read = FileRead($filef) $split = StringSplit($read,@LF) _ArrayDelete($split,$split[0]) $split[0] -= 1 For $i = 1 To $split[0] $files1[$i][0] = $split[$i] $files1[$i][1] = FileGetTime($split[$i],0,1) Next $files[0][0] = $split[0] _deleteArray("split") EndFunc i had to correct $files[0][0] with $files1[0][0] and $dir[0] with $dir1[0] Thanks
-
i tryed making a smallest program to demonstrate the problem, but i failed. It seems that only my full scritp make the error happen. here's the source: ;se c'è una cartella vuota (origine), dà errore #include <GUIConstants.au3> #include <EditConstants.au3> #include <FileToArray.au3> #include <Array.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> ;#include "IMAPI2.au3" #include <GuiComboBox.au3> #include <File.au3> $Form1 = GUICreate("BackupIt", 530, 423, 199, 128) $Tab1 = GUICtrlCreateTab(8, 8, 513, 385) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("Backup") $Label1 = GUICtrlCreateLabel("Origine:", 32, 48, 40, 17) $Input1 = GUICtrlCreateInput("", 112, 48, 193, 21, $ES_READONLY) $Button1 = GUICtrlCreateButton("...", 320, 48, 17, 17, 0) $Label2 = GUICtrlCreateLabel("Destinazione:", 32, 304, 68, 17) $Input2 = GUICtrlCreateInput("", 112, 304, 193, 21, $ES_READONLY) $Button2 = GUICtrlCreateButton("...", 320, 304, 17, 17, 0) $Button3 = GUICtrlCreateButton("BackupIt!", 376, 344, 121, 25, 0) $Label3 = GUICtrlCreateLabel("Stato: in attesa", 32, 344, 200, 17) $Button4 = GUICtrlCreateButton("Aggiungi", 376, 48, 65, 25, 0) $List1 = GUICtrlCreateList("", 32, 88, 305, 186, BitOR($LBS_SORT,$LBS_MULTIPLESEL,$WS_VSCROLL)) $Button5 = GUICtrlCreateButton("Rimuovi", 376, 112, 65, 25, 0) $Button6 = GUICtrlCreateButton("Salva", 376, 216, 65, 25, 0) $Button7 = GUICtrlCreateButton("Carica", 376, 248, 65, 25, 0) $TabSheet2 = GUICtrlCreateTabItem("Masterizza") $Label4 = GUICtrlCreateLabel("Masterizzatore da usare:", 40, 64, 119, 17) $Combo1 = GUICtrlCreateCombo("", 184, 64, 57, 25) $Button8 = GUICtrlCreateButton("Cancella CD/DVD", 24, 352, 105, 25, 0) $Button9 = GUICtrlCreateButton("Masterizza!", 408, 352, 97, 25, 0) $Label5 = GUICtrlCreateLabel("Azione in corso: in attesa", 40, 160, 200, 17) $Label6 = GUICtrlCreateLabel("Tempo rimanente: --", 40, 184, 200, 17) $Label7 = GUICtrlCreateLabel("Tempo trascorso: --", 40, 208, 200, 17) $Label8 = GUICtrlCreateLabel("Tempo totale: --", 40, 232, 200, 17) $Label9 = GUICtrlCreateLabel("Titolo:", 40, 112, 33, 17) $Input3 = GUICtrlCreateInput("Backup", 96, 112, 153, 21) GUICtrlCreateTabItem("") $Menu = GUICtrlCreateMenu("File") $Settings = GUICtrlCreateMenuItem("Impostazioni",$Menu) GUICtrlCreateMenuItem("",$Menu) $Exit = GUICtrlCreateMenuItem("Esci",$Menu) GUISetState(@SW_SHOW) Global $path Global $path1 Global $files[100000][2] Global $dir[100000] Global $files1[100000][2] Global $dir1[100000] Global $diff[100000][2];indirizzi file con data di modifica diversa Global $new[100000][2];indirizzi sul pc dei file nuovi Global $old[100000];indirizzi sul HD di file vecchi - non serve il tempo perché andranno cancellati Global $split Global $info Global $size = 0;dimensione delle cartelle da backuppare Global $fod;file di testo dove vengono salvati i percorsi delle directory Global $fof;file di testo dove vengono salvati i percorsi dei file $files[0][0] = 0 $files1[0][0] = 0 $dir[0] = 0 $dir1[0] = 0 Global $overwrite = INIRead(@ScriptDir & "\settings.ini","settings","overwrite","errore") Global $add = INIRead(@ScriptDir & "\settings.ini","settings","add","errore") Global $remove = INIRead(@ScriptDir & "\settings.ini","settings","remove","errore") #cs $ids = _IMAPI2_DrivesGetID();ID di tutti i drive $drivestring = '' For $i = 1 To $ids[0] $drive = _IMAPI2_DriveGetObj($ids[$i]);Obj del drive If $i = $ids[0] Then $drivestring = $drivestring & _IMAPI2_DriveGetLetter($drive) & ":\" Else $drivestring = $drivestring & _IMAPI2_DriveGetLetter($drive) & ":\|" EndIf Next $drive = _IMAPI2_DriveGetObj($ids[1]) GUICtrlSetData($Combo1,$drivestring,_IMAPI2_DriveGetLetter($drive)&":\") #ce While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Exit Exit Case $Settings _settings() Case $Button1;origine $path = FileSelectFolder("Selezionare la cartella di origine","",1) If $path <> "" Then GUICtrlSetData($Input1,$path) EndIf Case $Button2;destinazione $realpath1 = FileSelectFolder("Selezionare la cartella di destinazione","",1) If $realpath1 <> "" Then GUICtrlSetData($Input2,$realpath1) EndIf Case $Button4 If $path <> "" Then _GUICtrlListBox_AddString($List1,$path) $tempsize = DirGetSize($path) $size += $size EndIf Case $Button5 $selected = _GUICtrlListBox_GetSelItems($List1) If $selected[0] <> 0 Then For $i = 1 To $selected[0] _GUICtrlListBox_DeleteString($List1,$selected[$i]) Next EndIf Case $Button6 INIDelete(@ScriptDir & "\settings.ini", "directory") $itemcount = _GUICtrlListBox_GetCount($List1) For $i = 1 To $itemcount INIWrite(@ScriptDir & "\settings.ini","directory","dir"&$i,_GUICtrlListBox_GetText($List1,$i-1)) Next MsgBox(64,"Salvato","I percorsi delle cartelle sono stati salvati.") Case $Button7 $elements = INIReadSection(@ScriptDir & "\settings.ini", "directory") If Not @error Then $dim = UBound($elements,1) - 1 For $i = 1 To $dim _GUICtrlListBox_AddString($List1,$elements[$i][1]) Next EndIf Case $Button3 $itemcount = _GUICtrlListBox_GetCount($List1) For $i = 1 To $itemcount $path = _GUICtrlListBox_GetText($List1,$i-1) ;crea cartella nella destinazione e la setta come path1 $newdir = StringSplit($path,"\") $namedir = $newdir[$newdir[0]] $path1 = $realpath1 & $namedir DirCreate($path1) ;origine If $path <> '' Then GUICtrlSetData($Label3,'Stato: creazione lista origine...') $sourcestate = _fileListOr() If $sourcestate = 1 OR $sourcestate = 3 Then;cartella non valida o inesistente MsgBox(48,"Errore","La cartella di origine:"&@CRLF&$path&@CRLF&" non è valida o è inesistente.") GUICtrlSetData($Label3,'Stato: in attesa') ContinueLoop ElseIf $sourcestate = 2 Then;nessun file MsgBox(48,"Errore","La cartella di origine:"&@CRLF&$path&@CRLF&"non contiene file.") GUICtrlSetData($Label3,'Stato: in attesa') ContinueLoop EndIf GUICtrlSetData($Label3,'Stato: in attesa') Else MsgBox(48,"Errore","Non è stata selezionata una cartella di origine.") ContinueLoop EndIf ;destinazione If $path1 <> '' Then GUICtrlSetData($Label3,'Stato: creazione lista destinazione...') $deststate = _fileListDest() GUICtrlSetData($Label3,'Stato: in attesa') If $deststate = 1 OR $deststate = 3 Then MsgBox(48,"Errore","La cartella di destinazione:"&@CRLF&$path1&@CRLF&" non è valida o è inesistente.") GUICtrlSetData($Label3,'Stato: in attesa') ContinueLoop ElseIf $deststate = 2 Then $ask = MsgBox(4+48,"Nessun file","Nessun file trovato nella cartella di destinazione:"&@CRLF&$path1&@CRLF&"Eseguire una copia diretta?") If $ask = 6 Then GUICtrlSetData($Label3,'Stato: backup in corso...') _directCopy() GUICtrlSetData($Label3,'Stato: in attesa') MsgBox(64,"Finito!","Il backup è stato eseguito con successo!") Else MsgBox(48,"Abortito","Backup abortito.") EndIf Else _cutPathAddress() GUICtrlSetData($Label3,'Stato: comparazione liste...') _compareLists() GUICtrlSetData($Label3,'Stato: in attesa') ;file da aggiornare If $overwrite = 0 Then If $diff[0][0] <> 0 Then $wtd = MsgBox(4+48,"File da aggiornare","Sono stati trovati "&$diff[0][0]&" file da aggiornare."&@CRLF&"Eseguire l'aggiornamento?") If $wtd = 6 Then GUICtrlSetData($Label3,'Stato: aggiornamento file...') _updateFiles() EndIf EndIf ElseIf $overwrite = 1 Then _updateFiles() EndIf GUICtrlSetData($Label3,'Stato: in attesa') ;file nuovi If $add = 0 Then If $new[0][0] <> 0 Then $wtd = MsgBox(4+48,"File nuovi","Sono stati trovati "&$new[0][0]&" nuovi file."&@CRLF&"Aggiungerli al backup?") If $wtd = 6 Then GUICtrlSetData($Label3,'Stato: salvataggio nuovi file...') _addFiles() EndIf EndIf ElseIf $add = 1 Then _addFiles() EndIf GUICtrlSetData($Label3,'Stato: in attesa') ;file vecchi If $remove = 0 Then If $old[0] <> 0 Then $wtd = MsgBox(4+48,"File vecchi","Sono stati trovati "&$old[0]&" file non più presenti nella cartella d'origine."&@CRLF&"Eliminarli?") If $wtd = 6 Then GUICtrlSetData($Label3,'Stato: cancellazione file vecchi...') _deleteFiles() EndIf EndIf ElseIf $remove = 1 Then _deleteFiles() EndIf GUICtrlSetData($Label3,'Stato: in attesa') If $diff[0][0] = 0 AND $new[0][0] = 0 AND $old[0] = 0 Then MsgBox(64,"","I file presenti nella cartella di destinazione sono già aggiornati.") EndIf MsgBox(64,"Finito!","Il backup è stato eseguito con successo!") EndIf Else MsgBox(48,"Errore","Non è stata selezionata una cartella di destinazione.") ContinueLoop EndIf Next EndSwitch WEnd Func _progress($array) GUICtrlSetData($Label5,"Azione in corso: " & $array[0]) GUICtrlSetData($Label6,"Tempo rimanente: " & $array[1]) GUICtrlSetData($Label7,"Tempo trascorso: " & $array[2]) GUICtrlSetData($Label8,"Tempo totale: " & $array[3]) EndFunc Func _settings() $1Form1 = GUICreate("Impostazioni", 318, 215, 193, 125) $1Label1 = GUICtrlCreateLabel("Sovrascrivi i file non aggiornati", 120, 24, 147, 17) $1Label2 = GUICtrlCreateLabel("Aggiungi i file nuovi", 120, 56, 95, 17) $1Label3 = GUICtrlCreateLabel("Elimina i file vecchi", 120, 88, 93, 17) $1Button1 = GUICtrlCreateButton("Applica", 16, 168, 73, 25, 0) $1Button2 = GUICtrlCreateButton("Chiudi", 208, 168, 73, 25, 0) $1Combo1 = GUICtrlCreateCombo("Chiedi", 16, 24, 89, 25) If $overwrite = 0 Then GUICtrlSetData(-1,"Sempre|Mai") ElseIf $overwrite = 1 Then GUICtrlSetData(-1,"Sempre|Mai", "Sempre") Else GUICtrlSetData(-1,"Sempre|Mai", "Mai") EndIf $1Combo2 = GUICtrlCreateCombo("Chiedi", 16, 56, 89, 25) If $add = 0 Then GUICtrlSetData(-1,"Sempre|Mai") ElseIf $add = 1 Then GUICtrlSetData(-1,"Sempre|Mai", "Sempre") Else GUICtrlSetData(-1,"Sempre|Mai", "Mai") EndIf $1Combo3 = GUICtrlCreateCombo("Chiedi", 16, 88, 89, 25) If $remove = 0 Then GUICtrlSetData(-1,"Sempre|Mai") ElseIf $remove = 1 Then GUICtrlSetData(-1,"Sempre|Mai", "Sempre") Else GUICtrlSetData(-1,"Sempre|Mai", "Mai") EndIf GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE GuiDelete($1Form1) Return Case $1Button2 GuiDelete($1Form1) Return Case $1Button1 If GUICtrlRead($1Combo1) = "Chiedi" Then INIWrite(@ScriptDir & '\settings.ini','settings','overwrite',0) ElseIf GUICtrlRead($1Combo1) = "Sempre" Then INIWrite(@ScriptDir & '\settings.ini','settings','overwrite',1) Else INIWrite(@ScriptDir & '\settings.ini','settings','overwrite',-1) EndIf If GUICtrlRead($1Combo2) = "Chiedi" Then INIWrite(@ScriptDir & '\settings.ini','settings','add',0) ElseIf GUICtrlRead($1Combo2) = "Sempre" Then INIWrite(@ScriptDir & '\settings.ini','settings','add',1) Else INIWrite(@ScriptDir & '\settings.ini','settings','add',-1) EndIf If GUICtrlRead($1Combo3) = "Chiedi" Then INIWrite(@ScriptDir & '\settings.ini','settings','remove',0) ElseIf GUICtrlRead($1Combo3) = "Sempre" Then INIWrite(@ScriptDir & '\settings.ini','settings','remove',1) Else INIWrite(@ScriptDir & '\settings.ini','settings','remove',-1) EndIf $overwrite = INIRead(@ScriptDir & "\settings.ini","settings","overwrite","errore") $add = INIRead(@ScriptDir & "\settings.ini","settings","add","errore") $remove = INIRead(@ScriptDir & "\settings.ini","settings","remove","errore") EndSwitch WEnd EndFunc Func _directCopy() $len = StringLen($path) For $i = 1 To $files[0][0] $files[$i][0] = StringTrimLeft($files[$i][0],$len) Next For $i = 1 To $files[0][0] FileCopy($path & $files[$i][0], $path1 & $files[$i][0],9) FileSetTime($path1 & $files[$i][0],$files[$i][1]) Next EndFunc Func _deleteFiles() For $i = 1 To $old[0] FileRecycle($path1 & $old[$i]) Next EndFunc Func _addFiles() For $i = 1 To $new[0][0] $a = FileCopy($path & $new[$i][0], $path1 & $new[$i][0],9) FileSetTime($path1 & $new[$i][0], $new[$i][1]) Next EndFunc Func _updateFiles() For $i = 1 To $diff[0][0] FileCopy($path & $diff[$i][0], $path1 & $diff[$i][0],1) FileSetTime($path1 & $diff[$i][0], $diff[$i][1]) Next EndFunc Func _cutPathAddress() $len = StringLen($path) $len1 = StringLen($path1) For $i = 1 To $files[0][0] $files[$i][0] = StringTrimLeft($files[$i][0],$len) Next For $i = 1 To $dir[0] $dir[$i] = StringTrimLeft($dir[$i],$len) Next For $i = 1 To $files1[0][0] $files1[$i][0] = StringTrimLeft($files1[$i][0],$len1) Next For $i = 1 To $dir1[0] $dir1[$i] = StringTrimLeft($dir1[$i],$len1) Next EndFunc Func _compareLists() $k = 0 For $i = 1 To $files[0][0] For $j = 1 To $files1[0][0] If $files[$i][0] = $files1[$j][0] Then If $files[$i][1] <> $files1[$j][1] Then $k = $k + 1 $diff[$k][0] = $files[$i][0] $diff[$k][1] = $files[$i][1] ExitLoop EndIf EndIf Next Next $diff[0][0] = $k $k = 0 For $i = 1 To $files[0][0] $state = false For $j = 1 To $files1[0][0] If $files[$i][0] = $files1[$j][0] Then $state = true ExitLoop EndIf Next If $state = false Then $k = $k + 1 $new[$k][0] = $files[$i][0] $new[$k][1] = $files[$i][1] EndIf Next $new[0][0] = $k $k = 0 For $j = 1 To $files1[0][0] $state = false For $i = 1 To $files[0][0] If $files1[$j][0] = $files[$i][0] Then $state = true ExitLoop EndIf Next If $state = false Then $k = $k + 1 $old[$k] = $files1[$j][0] EndIf Next $old[0] = $k EndFunc Func _fileListOr() ;creazione liste If FileExists(@ScriptDir & "\sourced.txt") Then FileDelete(@ScriptDir & "\sourced.txt") EndIf If FileExists(@ScriptDir & "\sourcef.txt") Then FileDelete(@ScriptDir & "\sourcef.txt") EndIf $filed = @ScriptDir & "\sourced.txt" $filef = @ScriptDir & "\sourcef.txt" $info = DirGetSize($path,1) If $info[1] = 0 AND $info[2] = 0 Then _deleteArray("info") Return 2 EndIf $fod = FileOpen($filed,2) $fof = FileOpen($filef,2) $search = _SearchFolder($path) FileClose($fod) FileClose($fof) If $search = 1 Then;cartella non valida o inesistente [file] Return 1 ElseIf $search = 3 Then;cartella non valida o inesistente [directory] Return 3 EndIf ;lettura cartelle $read = FileRead($filed) $split = StringSplit($read,@LF) _ArrayDelete($split,$split[0]) $split[0] -= 1 For $i = 1 To $split[0] $dir[$i] = $split[$i] Next $dir[0] = $split[0] _deleteArray("split") ;lettura file $read = FileRead($filef) $split = StringSplit($read,@LF) _ArrayDelete($split,$split[0]) $split[0] -= 1 For $i = 1 To $split[0] $files[$i][0] = $split[$i] $files[$i][1] = FileGetTime($split[$i],0,1) Next $files[0][0] = $split[0] _deleteArray("split") EndFunc Func _fileListDest() ;creazione liste If FileExists(@ScriptDir & "\destd.txt") Then FileDelete(@ScriptDir & "\destd.txt") EndIf If FileExists(@ScriptDir & "\destf.txt") Then FileDelete(@ScriptDir & "\destf.txt") EndIf $filed = @ScriptDir & "\destd.txt" $filef = @ScriptDir & "\destf.txt" $info = DirGetSize($path1,1) If $info[1] = 0 AND $info[2] = 0 Then _deleteArray("info") Return 2 EndIf $fod = FileOpen($filed,2) $fof = FileOpen($filef,2) $search = _SearchFolder($path1) FileClose($fod) FileClose($fof) If $search = 1 Then;cartella non valida o inesistente [file] Return 1 ElseIf $search = 3 Then;cartella non valida o inesistente [directory] Return 3 EndIf ;lettura cartelle $read = FileRead($filed) $split = StringSplit($read,@LF) _ArrayDelete($split,$split[0]) $split[0] -= 1 For $i = 1 To $split[0] $dir1[$i] = $split[$i] Next $dir[0] = $split[0] _deleteArray("split") ;lettura file $read = FileRead($filef) $split = StringSplit($read,@LF) _ArrayDelete($split,$split[0]) $split[0] -= 1 For $i = 1 To $split[0] $files1[$i][0] = $split[$i] $files1[$i][1] = FileGetTime($split[$i],0,1) Next $files[0][0] = $split[0] _deleteArray("split") EndFunc Func _SearchFolder($folder) $sFiles = _FileListToArray($folder,"*",1) If @error = 1 Then Return 1 EndIf $sFolders = _FileListToArray($folder,"*",2) If @error = 1 Then Return 3 EndIf _FileFunc($sFiles,$folder) _FolderFunc($sFolders,$folder) EndFunc Func _FileFunc($sFiles,$folder) For $i = 1 To UBound($sFiles)-1 FileWrite($fof, $folder & "\" & $sFiles[$i] & @LF) Next EndFunc Func _FolderFunc($sFolders,$parentdir) For $i = 1 To UBound($sFolders)-1 FileWrite($fod, $parentdir & "\" & $sFolders[$i] & @LF) _SearchFolder($parentdir & "\" & $sFolders[$i]) Next EndFunc Func _deleteArray($which) Switch $which Case "split" For $i = ($split[0] + 1) To 0 Step -1 _ArrayDelete($split,$i) Next Case "info" For $i = 2 To 0 Step -1 _ArrayDelete($info,$i) Next EndSwitch EndFunc the problem happens when function _directCopy() is used, but i can't find any logical error q.q
-
Hi. I've a big problem with FileGetTime and FileSetTime functions. In my script, i save in an array the times of last modification of some files, then i copy this files in another folder and set their time equal to the original ones, using the array and FileSetTime. The problem is that the setted times for the new files is sometime wrong. Not for all the files, but some of them have a different time. I donnow where is the problem, i only get the time from the originals -> save it in an array -> set the time on the copy. I don't manipulate them. Can you help me please? (the script is 651 line long, written in italian and with an horrible coding skill...don't ask to post it if you're not a masochist)
-
You're right, man! I feel so stupid >.< Thanks
-
it's really long #include <GUIConstants.au3> #include <EditConstants.au3> #include <FileToArray.au3> #include <Array.au3> $Form1 = GUICreate("Backup To HD", 346, 226, 193, 125) GUISetBkColor(0xFF9900,$Form1) $Label1 = GUICtrlCreateLabel("Origine:", 48, 64, 40, 17) $Label2 = GUICtrlCreateLabel("Destinazione:", 24, 112, 68, 17) $Label3 = GUICtrlCreateLabel("Stato: in attesa", 120, 144, 150, 17) $Input1 = GUICtrlCreateInput("", 104, 56, 193, 21, $ES_READONLY) $Input2 = GUICtrlCreateInput("", 104, 104, 193, 21, $ES_READONLY) $Button1 = GUICtrlCreateButton("...", 304, 56, 17, 17, 0) $Button2 = GUICtrlCreateButton("...", 304, 104, 17, 17, 0) $Button3 = GUICtrlCreateButton("Backup!", 120, 176, 137, 33, 0) $Menu = GUICtrlCreateMenu("File") $Settings = GUICtrlCreateMenuItem("Impostazioni",$Menu) GUICtrlCreateMenuItem("",$Menu) $Exit = GUICtrlCreateMenuItem("Esci",$Menu) GUISetState(@SW_SHOW) Global $path Global $path1 Global $files[100000][2] Global $dir[100000] Global $files1[100000][2] Global $dir1[100000] Global $diff[100000][2];indirizzi file con data di modifica diversa Global $new[100000][2];indirizzi sul pc dei file nuovi Global $old[100000];indirizzi sul HD di file vecchi - non serve il tempo perché andranno cancellati Global $tfiles Global $tdir $files[0][0] = 0 $files1[0][0] = 0 $dir[0] = 0 $dir1[0] = 0 $alwaysOverwrite = INIRead(@ScriptDir & "\settings.ini","settings","alwaysOverwrite","errore") $alwaysAdd = INIRead(@ScriptDir & "\settings.ini","settings","alwaysAdd","errore") $alwaysRemove = INIRead(@ScriptDir & "\settings.ini","settings","alwaysRemove","errore") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Exit Exit Case $Settings _settings() Case $Button1 $path = FileSelectFolder("Selezionare la cartella","") If $path = "" Then ContinueLoop Else GUICtrlSetData($Input1,$path) EndIf Case $Button2 $path1 = FileSelectFolder("Selezionare la cartella","") If $path1 = "" Then ContinueLoop Else GUICtrlSetData($Input2,$path1) EndIf Case $Button3 ;origine If GUICtrlRead($Input1) <> '' Then GUICtrlSetData($Label3,'Stato: creazione lista origine...') _fileListOr() GUICtrlSetState($Button3,$GUI_ENABLE) GUICtrlSetData($Label3,'Stato: in attesa') Else MsgBox(48,"Errore","Non è stata selezionata una cartella di origine.") ContinueLoop EndIf ;destinazione If GUICtrlRead($Input2) <> '' Then GUICtrlSetData($Label3,'Stato: creazione lista destinazione...') $diststate = _fileListDest() GUICtrlSetData($Label3,'Stato: in attesa') If $diststate = 1 Then GUICtrlSetData($Label3,'Stato: in attesa') ElseIf $diststate = 2 Then GUICtrlSetData($Label3,'Stato: in attesa') MsgBox(64,"Finito!","Il backup è stato eseguito con successo!") Else _cutPathAddress() GUICtrlSetData($Label3,'Stato: comparazione liste...') _compareLists() GUICtrlSetData($Label3,'Stato: in attesa') If $diff[0][0] <> 0 Then;file da aggiornare $wtd = MsgBox(4+48,"File da aggiornare","Sono stati trovati "&$diff[0][0]&" file da aggiornare."&@CRLF&"Eseguire l'aggiornamento?") If $wtd = 6 Then GUICtrlSetData($Label3,'Stato: aggiornamento file...') _updateFiles() EndIf EndIf GUICtrlSetData($Label3,'Stato: in attesa') If $new[0][0] <> 0 Then;file nuovi $wtd = MsgBox(4+48,"File nuovi","Sono stati trovati "&$new[0][0]&" nuovi file."&@CRLF&"Aggiungerli al backup?") If $wtd = 6 Then GUICtrlSetData($Label3,'Stato: salvataggio nuovi file...') _addFiles() EndIf EndIf GUICtrlSetData($Label3,'Stato: in attesa') If $old[0] <> 0 Then;file vecchi $wtd = MsgBox(4+48,"File vecchi","Sono stati trovati "&$old[0]&" file non più presenti nella cartella d'origine."&@CRLF&"Eliminarli?") If $wtd = 6 Then GUICtrlSetData($Label3,'Stato: cancellazione file vecchi...') _deleteFiles() EndIf EndIf GUICtrlSetData($Label3,'Stato: in attesa') If $diff[0][0] = 0 AND $new[0][0] = 0 AND $old[0][0] = 0 Then MsgBox(64,"","I file presenti nella cartella di destinazione sono già aggiornati.") MsgBox(64,"Finito!","Il backup è stato eseguito con successo!") EndIf Else MsgBox(48,"Errore","Non è stata selezionata una cartella di destinazione.") ContinueLoop EndIf EndSwitch WEnd #cs Func _settings() EndFunc #ce Func _directCopy() $len = StringLen($path) For $i = 1 To $files[0][0] $files[$i][0] = StringTrimLeft($files[$i][0],$len) Next For $i = 1 To $files[0][0] FileCopy($path & $files[$i][0], $path1 & $files[$i][0],9) FileSetTime($path1,$files[$i][1]) Next EndFunc Func _deleteFiles() For $i = 1 To $old[0] FileRecycle($path1 & $old[$i]) Next EndFunc Func _addFiles() For $i = 1 To $new[0][0] $a = FileCopy($path & $new[$i][0], $path1 & $new[$i][0],9) FileSetTime($path1 & $new[$i][0], $new[$i][1]) Next EndFunc Func _updateFiles() For $i = 1 To $diff[0][0] FileCopy($path & $diff[$i][0], $path1 & $diff[$i][0],1) FileSetTime($path1 & $diff[$i][0], $diff[$i][1]) Next EndFunc Func _cutPathAddress() $len = StringLen($path) $len1 = StringLen($path1) For $i = 1 To $files[0][0] $files[$i][0] = StringTrimLeft($files[$i][0],$len) Next For $i = 1 To $dir[0] $dir[$i] = StringTrimLeft($dir[$i],$len) Next For $i = 1 To $files1[0][0] $files1[$i][0] = StringTrimLeft($files1[$i][0],$len1) Next For $i = 1 To $dir1[0] $dir1[$i] = StringTrimLeft($dir1[$i],$len1) Next EndFunc Func _compareLists() $k = 0 For $i = 1 To $files[0][0] For $j = 1 To $files1[0][0] If $files[$i][0] = $files1[$j][0] Then If $files[$i][1] <> $files1[$j][1] Then $k = $k + 1 $diff[$k][0] = $files[$i][0] $diff[$k][1] = $files[$i][1] ExitLoop EndIf EndIf Next Next $diff[0][0] = $k $k = 0 For $i = 1 To $files[0][0] $state = false For $j = 1 To $files1[0][0] If $files[$i][0] = $files1[$j][0] Then $state = true ExitLoop EndIf Next If $state = false Then $k = $k + 1 $new[$k][0] = $files[$i][0] $new[$k][1] = $files[$i][1] EndIf Next $new[0][0] = $k $k = 0 For $j = 1 To $files1[0][0] $state = false For $i = 1 To $files[0][0] If $files1[$j][0] = $files[$i][0] Then $state = true ExitLoop EndIf Next If $state = false Then $k = $k + 1 $old[$k] = $files1[$j][0] EndIf Next $old[0] = $k EndFunc Func _fileListOr() $tfiles = _FileListToArrayEx($path,'*.*',1,'') If @error = 1 Then MsgBox(48,"Errore","Cartella di origine non trovata o invalida.") Return EndIf If IsArray($tfiles) Then For $i = 0 To $tfiles[0] If $i = $tfiles[0] Then $files[0][0] = $i ExitLoop EndIf $files[$i+1][0] = $tfiles[$i+1] $files[$i+1][1] = FileGetTime($tfiles[$i+1],0,1) Next _deleteArray('files') EndIf $tdir = _FileListToArrayEx($path,'*',2,'') If @error = 1 Then MsgBox(48,"Errore","Cartella di origine non trovata o invalida.") Return EndIf If IsArray($tdir) Then For $i = 0 To $tdir[0] If $i = $tdir[0] Then $dir[0] = $i ExitLoop EndIf $dir[$i+1] = $tdir[$i+1] Next _deleteArray('dir') EndIf $j = 1 While 1 $tdir = _FileListToArrayEx($dir[$j],'*',2,'') If IsArray($tdir) Then For $i = 0 To $tdir[0] If $i = $tdir[0] Then $dir[0] = $dir[0] + $i ExitLoop EndIf $dir[1+$i+$dir[0]] = $tdir[$i+1] Next _deleteArray('dir') EndIf $j = $j + 1 If $j > $dir[0] Then ExitLoop EndIf WEnd For $j = 1 To $dir[0] $tfiles = _FileListToArrayEx($dir[$j],'*.*',1,'') If IsArray($tfiles) Then For $i = 0 To $tfiles[0] If $i = $tfiles[0] Then $files[0][0] = $files[0][0] + $i ExitLoop EndIf $files[1+$i+$files[0][0]][0] = $tfiles[$i+1] $files[1+$i+$files[0][0]][1] = FileGetTime($tfiles[$i+1],0,1) Next _deleteArray('files') EndIf Next EndFunc Func _fileListDest() $tfiles = _FileListToArrayEx($path1,'*.*',1,'') If @error = 1 Then MsgBox(48,"Errore","Cartella di destinazione non trovata o invalida.") Return EndIf $xyz = 0 If @error = 4 Then $xyz = 1 EndIf If IsArray($tfiles) Then For $i = 0 To $tfiles[0] If $i = $tfiles[0] Then $files1[0][0] = $i ExitLoop EndIf $files1[$i+1][0] = $tfiles[$i+1] $files1[$i+1][1] = FileGetTime($tfiles[$i+1],0,1) Next _deleteArray('files') EndIf SetError(0) $tdir = _FileListToArrayEx($path1,'*',2,'') If @error = 1 Then MsgBox(48,"Errore","Cartella di destinazione non trovata o invalida.") Return EndIf $xyz1 = 0 If IsArray($tdir) AND ($tdir[0] <> 1) AND ($tdir[1] <> $path1 & '\') Then For $i = 0 To $tdir[0] If $i = $tdir[0] Then $dir1[0] = $i ExitLoop EndIf $dir1[$i+1] = $tdir[$i+1] Next _deleteArray('dir') Else $xyz1 = 1 EndIf If ($xyz = 1) AND ($xyz1 = 1) Then $ask = MsgBox(4+48,"Nessun file","Nessun file trovato nella cartella di destinazione."&@CRLF&"Eseguire una copia diretta?") If $ask = 6 Then GUICtrlSetData($Label3,'Stato: backup in corso...') _directCopy() Return 2 Else MsgBox(48,"Abortito","Backup abortito.") Return 1 EndIf EndIf $j = 1 While 1 $tdir = _FileListToArrayEx($dir1[$j],'*',2,'') If IsArray($tdir) Then For $i = 0 To $tdir[0] If $i = $tdir[0] Then $dir1[0] = $dir1[0] + $i ExitLoop EndIf $dir1[1+$i+$dir1[0]] = $tdir[$i+1] Next _deleteArray('dir') EndIf $j = $j + 1 If $j > $dir1[0] Then ExitLoop EndIf WEnd For $j = 1 To $dir1[0] $tfiles = _FileListToArrayEx($dir1[$j],'*.*',1,'') If IsArray($tfiles) Then For $i = 0 To $tfiles[0] If $i = $tfiles[0] Then $files1[0][0] = $files1[0][0] + $i ExitLoop EndIf $files1[1+$i+$files1[0][0]][0] = $tfiles[$i+1] $files1[1+$i+$files1[0][0]][1] = FileGetTime($tfiles[$i+1],0,1) Next _deleteArray('files') EndIf Next EndFunc Func _deleteArray($which) If $which = 'files' Then For $i = ($tfiles[0] + 1) To 0 Step -1 _ArrayDelete($tfiles,$i) Next ElseIf $which = 'dir' Then For $i = ($tdir[0] + 1) To 0 Step -1 _ArrayDelete($tdir,$i) Next EndIf EndFunc you also need FileToArray.au3 ;=============================================================================== ; ; Description: lists all or preferred files and or folders in a specified path (Similar to using Dir with the /B Switch) ; Syntax: _FileListToArrayEx($sPath, $sFilter = '*.*', $iFlag = 0, $sExclude = '') ; Parameter(s): $sPath = Path to generate filelist for ; $sFilter = The filter to use. Search the Autoit3 manual for the word "WildCards" For details, support now for multiple searches ; Example *.exe; *.txt will find all .exe and .txt files ; $iFlag = determines weather to return file or folders or both. ; $sExclude = exclude a file from the list by all or part of its name ; Example: Unins* will remove all files/folders that start with Unins ; $iFlag=0(Default) Return both files and folders ; $iFlag=1 Return files Only ; $iFlag=2 Return Folders Only ; ; Requirement(s): None ; Return Value(s): On Success - Returns an array containing the list of files and folders in the specified path ; On Failure - Returns the an empty string "" if no files are found and sets @Error on errors ; @Error or @extended = 1 Path not found or invalid ; @Error or @extended = 2 Invalid $sFilter or Invalid $sExclude ; @Error or @extended = 3 Invalid $iFlag ; @Error or @extended = 4 No File(s) Found ; ; Author(s): SmOke_N ; Note(s): The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Files\Folders returned ; $array[1] = 1st File\Folder ; $array[2] = 2nd File\Folder ; $array[3] = 3rd File\Folder ; $array[n] = nth File\Folder ; ; All files are written to a "reserved" .tmp file (Thanks to gafrost) for the example ; The Reserved file is then read into an array, then deleted ;=============================================================================== Func _FileListToArrayEx($sPath, $sFilter = '*.*', $iFlag = 0, $sExclude = '', $iRecurse = False) If Not FileExists($sPath) Then Return SetError(1, 1, '') If $sFilter = -1 Or $sFilter = Default Then $sFilter = '*.*' If $iFlag = -1 Or $iFlag = Default Then $iFlag = 0 If $sExclude = -1 Or $sExclude = Default Then $sExclude = '' Local $aBadChar[6] = ['\', '/', ':', '>', '<', '|'] $sFilter = StringRegExpReplace($sFilter, '\s*;\s*', ';') If StringRight($sPath, 1) <> '\' Then $sPath &= '\' For $iCC = 0 To 5 If StringInStr($sFilter, $aBadChar[$iCC]) Or _ StringInStr($sExclude, $aBadChar[$iCC]) Then Return SetError(2, 2, '') Next If StringStripWS($sFilter, 8) = '' Then Return SetError(2, 2, '') If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, '') Local $oFSO = ObjCreate("Scripting.FileSystemObject"), $sTFolder $sTFolder = $oFSO.GetSpecialFolder(2) Local $hOutFile = @TempDir & $oFSO.GetTempName If Not StringInStr($sFilter, ';') Then $sFilter &= ';' Local $aSplit = StringSplit(StringStripWS($sFilter, 8), ';'), $sRead, $sHoldSplit For $iCC = 1 To $aSplit[0] If StringStripWS($aSplit[$iCC],8) = '' Then ContinueLoop If StringLeft($aSplit[$iCC], 1) = '.' And _ UBound(StringSplit($aSplit[$iCC], '.')) - 2 = 1 Then $aSplit[$iCC] = '*' & $aSplit[$iCC] $sHoldSplit &= '"' & $sPath & $aSplit[$iCC] & '" ' Next $sHoldSplit = StringTrimRight($sHoldSplit, 1) If $iRecurse Then RunWait(@Comspec & ' /c dir /b /s /a ' & $sHoldSplit & ' > "' & $hOutFile & '"', '', @SW_HIDE) Else RunWait(@ComSpec & ' /c dir /b /a ' & $sHoldSplit & ' /o-e /od > "' & $hOutFile & '"', '', @SW_HIDE) EndIf $sRead &= FileRead($hOutFile) If Not FileExists($hOutFile) Then Return SetError(4, 4, '') FileDelete($hOutFile) If StringStripWS($sRead, 8) = '' Then SetError(4, 4, '') Local $aFSplit = StringSplit(StringTrimRight(StringStripCR($sRead), 1), @LF) Local $sHold For $iCC = 1 To $aFSplit[0] If $sExclude And StringLeft($aFSplit[$iCC], _ StringLen(StringReplace($sExclude, '*', ''))) = StringReplace($sExclude, '*', '') Then ContinueLoop Switch $iFlag Case 0 If StringRegExp($aFSplit[$iCC], '\w:\\') = 0 Then $sHold &= $sPath & $aFSplit[$iCC] & Chr(1) Else $sHold &= $aFSplit[$iCC] & Chr(1) EndIf Case 1 If StringInStr(FileGetAttrib($sPath & '\' & $aFSplit[$iCC]), 'd') = 0 And _ StringInStr(FileGetAttrib($aFSplit[$iCC]), 'd') = 0 Then If StringRegExp($aFSplit[$iCC], '\w:\\') = 0 Then $sHold &= $sPath & $aFSplit[$iCC] & Chr(1) Else $sHold &= $aFSplit[$iCC] & Chr(1) EndIf EndIf Case 2 If StringInStr(FileGetAttrib($sPath & '\' & $aFSplit[$iCC]), 'd') Or _ StringInStr(FileGetAttrib($aFSplit[$iCC]), 'd') Then If StringRegExp($aFSplit[$iCC], '\w:\\') = 0 Then $sHold &= $sPath & $aFSplit[$iCC] & Chr(1) Else $sHold &= $aFSplit[$iCC] & Chr(1) EndIf EndIf EndSwitch Next If StringTrimRight($sHold, 1) Then Return StringSplit(StringTrimRight($sHold, 1), Chr(1)) Return SetError(4, 4, '') EndFunc
-
you have to use 2 different arrays
-
Hi I just finished to code a new program, but when i try to execute it, Scite give me this error: (125) : ==> "EndSwitch" statement with no matching "Switch" statement.: EndSwitch This is the code, it's a bit long. I really can't find the error. While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Exit Exit Case $Settings _settings() Case $Button1 $path = FileSelectFolder("Selezionare la cartella","") If $path = "" Then ContinueLoop Else GUICtrlSetData($Input1,$path) EndIf Case $Button2 $path1 = FileSelectFolder("Selezionare la cartella","") If $path1 = "" Then ContinueLoop Else GUICtrlSetData($Input2,$path1) EndIf Case $Button3 ;origine If GUICtrlRead($Input1) <> '' Then GUICtrlSetData($Label3,'Stato: creazione lista origine...') _fileListOr() GUICtrlSetState($Button3,$GUI_ENABLE) GUICtrlSetData($Label3,'Stato: in attesa') Else MsgBox(48,"Errore","Non è stata selezionata una cartella di origine.") ContinueLoop EndIf ;destinazione If GUICtrlRead($Input2) <> '' Then GUICtrlSetData($Label3,'Stato: creazione lista destinazione...') $diststate = _fileListDest() GUICtrlSetData($Label3,'Stato: in attesa') If $diststate = 1 Then GUICtrlSetData($Label3,'Stato: in attesa') ElseIf $diststate = 2 Then GUICtrlSetData($Label3,'Stato: in attesa') MsgBox(64,"Finito!","Il backup è stato eseguito con successo!") Else _cutPathAddress() GUICtrlSetData($Label3,'Stato: comparazione liste...') _compareLists() GUICtrlSetData($Label3,'Stato: in attesa') If $diff[0][0] <> 0 Then;file da aggiornare $wtd = MsgBox(4+48,"File da aggiornare","Sono stati trovati "&$diff[0][0]&" file da aggiornare."&@CRLF&"Eseguire l'aggiornamento?") If $wtd = 6 Then GUICtrlSetData($Label3,'Stato: aggiornamento file...') _updateFiles() EndIf EndIf GUICtrlSetData($Label3,'Stato: in attesa') If $new[0][0] <> 0 Then;file nuovi $wtd = MsgBox(4+48,"File nuovi","Sono stati trovati "&$new[0][0]&" nuovi file."&@CRLF&"Aggiungerli al backup?") If $wtd = 6 Then GUICtrlSetData($Label3,'Stato: salvataggio nuovi file...') _addFiles() EndIf EndIf GUICtrlSetData($Label3,'Stato: in attesa') If $old[0] <> 0 Then;file vecchi $wtd = MsgBox(4+48,"File vecchi","Sono stati trovati "&$old[0]&" file non più presenti nella cartella d'origine."&@CRLF&"Eliminarli?") If $wtd = 6 Then GUICtrlSetData($Label3,'Stato: cancellazione file vecchi...') _deleteFiles() EndIf EndIf GUICtrlSetData($Label3,'Stato: in attesa') If $diff[0][0] = 0 AND $new[0][0] = 0 AND $old[0][0] = 0 Then MsgBox(64,"","I file presenti nella cartella di destinazione sono già aggiornati.") MsgBox(64,"Finito!","Il backup è stato eseguito con successo!") EndIf Else MsgBox(48,"Errore","Non è stata selezionata una cartella di destinazione.") ContinueLoop EndIf EndSwitch WEnd
-
sorry, but in the description you wrote this however, error persists
-
here's the code. In the first part it searches for all profiles folders $profili = _FileListToArray(@AppDataDir&"\Mozilla\Firefox\Profiles","*.default",2) then it saves in an array all the signons*.txt's path Dim $signons[100][100] For $i = 1 To $profili[0] $search = FileFindFirstFile(@AppDataDir&"\Mozilla\Firefox\Profiles\"&$profili[$i]&"\signons*.txt") $k = 1 While @error <> 1 $temp = FileFindNextFile($search) If $temp = '' Then ExitLoop $signons[$i][$k] = @AppDataDir&"\Mozilla\Firefox\Profiles\"&$profili[$i]&"\"&$temp; i = profilo in cui cerca; k = posizione dell'array in cui salva il percorso dei signons di quel profilo $k += 1 WEnd $signons[$i][0] = $k Next then it creates a zip file for each profile Dim $zip[100] For $i = 1 To $profili[0] ;ConsoleWrite("Percorso profilo "&$i&" :"&@AppDataDir&"\Mozilla\Firefox\Profiles\"&$profili[$i]&@CRLF) $zip[$i] = _Zip_Create(@AppDataDir&"\Mozilla\Firefox\"&$i&".zip") Next $zip[0] = $i in the end it adds the signons*.txt files to the zip file For $i = 1 To $profili[0] For $k = 1 To $signons[$i][0] If $signons[$i][$k] <> '' Then ;ConsoleWrite("Percorso signonons*.txt "&$k&" e profilo "&$i&" :"&$signons[$i][$k]&@CRLF) _Zip_AddFile($zip[$i],$signons[$i][$k],1) EndIf Next Next the problem happens in this last part of code
-
hi, i'm makin a tool to backup firefox's password files (key3.db, signons*.txt). I'm using your UDF to zip them all, but during test an error occurred: C:\Documents and Settings\*****\Desktop\Autoit\FirefoxPassBackup\ZIP.au3 (315) : ==> Object referenced outside a "With" statement.: $hList = $oApp.Namespace($hZipFile).Items $hList = $oApp.Namespace($hZipFile)^ ERROR i think this happens becouse your UDF try to _Zip_List an empty zip-file, before i can add a file. how to solve it?