Aceguy Posted July 30, 2008 Share Posted July 30, 2008 here is my script, and when it starts to copy (only large files) sometimes it stops responding and reports the file copy as being FAILED. but all files are copied. I'm completely stummped. any ideas...... its a large script. expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=..\Icon Entry_573.ico #AutoIt3Wrapper_outfile=..\D Backup.exe #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include<GUIConstantsEx.au3> #include<WindowsConstants.au3> #include<Array.au3> #include<ButtonConstants.au3> #include<Date.au3> #include<GuiImageList.au3> #include<GuiListView.au3> #include<ListViewConstants.au3> #include<StaticConstants.au3> #include<StructureConstants.au3> If WinExists("My Backup V1.3") = 1 Then MsgBox(16, "Error!", "Already Running!!!" & @CRLF & "Not running another instance.") Exit EndIf $inifile = @MyDocumentsDir & "\Backup.ini" Global Const $HDN_FIRST = -300 Global Const $HDN_ITEMCHANGINGA = $HDN_FIRST - 0 Global Const $HDN_BEGINTRACKA = $HDN_FIRST - 6 Global $hListView, $ir, $yh, $_dir_copy, $ws_start Global $Gui, $GuiContext[2], $Tray[2], $b1, $b2, $b3, $b4, $b5 Global $menu1Chk = 1 $tray_pop = False $day_year = @YDAY $min = @MIN Opt("GUIOnEventMode", 1) Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) $ty = IniRead($inifile, "winpos", 0, 'error') If $ty <> 'error' Then $ss3 = StringSplit($ty, "|") $x = $ss3[1] $y = $ss3[2] $yh = $ss3[4] Else $yh = 200 $x = 400 $y = 300 EndIf $Gui = GUICreate("My Backup V1.3", 500, $yh, $x, $y, $WS_SIZEBOX, $WS_EX_TOOLWINDOW) $GuiContext[0] = GUICtrlCreateContextMenu() $GuiContext[1] = GUICtrlCreateMenuItem("Send To Tray", $GuiContext[0]) GUICtrlSetOnEvent(-1, "HideShow") GUISetOnEvent($GUI_EVENT_CLOSE, "quit") $add_folder = GUICtrlCreateButton('', 10, 10, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 46) GUICtrlSetOnEvent(-1, "add_folder") GUICtrlSetTip(-1, "Backup a Complete Folder") GUICtrlSetResizing(-1, $GUI_DOCKALL) $add_file = GUICtrlCreateButton('', 55, 10, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 134) GUICtrlSetOnEvent(-1, "add_file") GUICtrlSetTip(-1, "Backup a Single File") GUICtrlSetResizing(-1, $GUI_DOCKALL) $output_foler = GUICtrlCreateButton('', 450, 10, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 146) GUICtrlSetOnEvent(-1, "output_folder") GUICtrlSetResizing(-1, $GUI_DOCKALL) $backup_now = GUICtrlCreateButton('', 410, 10, 40, 40, $BS_ICON) GUICtrlSetTip(-1, "Right Click For more Options") GUICtrlSetImage(-1, "shell32.dll", 7) GUICtrlSetOnEvent(-1, "backup_now") GUICtrlSetResizing(-1, $GUI_DOCKALL) $b1 = GUICtrlCreateContextMenu($backup_now) $b2 = GUICtrlCreateMenuItem("Full - All Items", $b1) GUICtrlSetOnEvent(-1, "con_men") GUICtrlSetState(-1, $GUI_CHECKED) $b3 = GUICtrlCreateMenuItem("Partial - Only Marked With X", $b1) GUICtrlSetOnEvent(-1, "con_men2") $b4 = GUICtrlCreateMenuItem("", $b1) $b5 = GUICtrlCreateMenuItem("Start when Windows start", $b1) GUICtrlSetOnEvent(-1, "windows_start") $combo1 = GUICtrlCreateCombo('Please Select', 100, 10, 100, 25) GUICtrlSetData(-1, 'Daily|Weekly|Monthly') GUICtrlSetResizing(-1, $GUI_DOCKALL) $log = GUICtrlCreateLabel("Message Log", 210, 10, 175, 15, $SS_SUNKEN) GUICtrlSetBkColor(-1, 0xffffff) GUICtrlSetResizing(-1, $GUI_DOCKALL) $progress = GUICtrlCreateProgress(210, 30, 175, 10) GUICtrlSetColor($progress, 0x00FF00) GUICtrlSetBkColor($progress, 0x00ff00) GUICtrlSetCursor(-1, 7) GUICtrlSetResizing(-1, $GUI_DOCKALL) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", " ", "wstr", " ") GUICtrlSetStyle(-1, 1) $progress2 = GUICtrlCreateProgress(210, 40, 175, 10) GUICtrlSetColor($progress2, 0x00FF00) GUICtrlSetBkColor($progress2, 0x00ff00) GUICtrlSetCursor(-1, 7) GUICtrlSetResizing(-1, $GUI_DOCKALL) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", " ", "wstr", " ") GUICtrlSetStyle(-1, 1) $hListView = GUICtrlCreateListView("Name|Location|Sched|Comments|D|", 10, 55, 480, $yh - 80, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT, $LVS_NOSORTHEADER)) GUICtrlSetResizing($hListView, $GUI_DOCKBOTTOM + $GUI_DOCKTOP) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_INFOTIP)) _GUICtrlListView_SetColumnWidth($hListView, 0, 75);name _GUICtrlListView_SetColumnWidth($hListView, 1, 215);location _GUICtrlListView_SetColumnWidth($hListView, 2, 50);schedule _GUICtrlListView_SetColumnWidth($hListView, 3, 90);comments _GUICtrlListView_SetColumnWidth($hListView, 4, 25);delete $hImage = _GUIImageList_Create(16, 16, 5, 5) _GUIImageList_AddIcon($hImage, "shell32.dll", 4);folder 0 _GUIImageList_AddIcon($hImage, "shell32.dll", 54);file 1 _GUIImageList_AddIcon($hImage, "shell32.dll", 31);bin 2 _GUIImageList_AddIcon($hImage, "shell32.dll", 21);tick 3 _GUIImageList_AddIcon($hImage, "shell32.dll", 131);cross 4 _GUICtrlListView_SetImageList($hListView, $hImage, 1) $Tray[1] = TrayCreateItem("Exit Daily Backup") TrayItemSetOnEvent(-1, "quit") TraySetOnEvent(-7, "HideShow") TraySetClick(16) TraySetState(1) $Tray[0] = 1 $iread = IniRead($inifile, "config", 0, 'error') If $iread = 'error' Then GUICtrlSetState($add_file, $gui_disable) GUICtrlSetState($add_folder, $gui_disable) GUICtrlSetState($backup_now, $gui_disable) GUICtrlSetState($combo1, $gui_disable) If @OSVersion = 'WIN_VISTA' Then MsgBox(4144, "Warning!!", "Windows VISTA Detected" & @CRLF & "To enable start when windows start" & @CRLF & "Run as Administartor and Disable UAC", 0) GUICtrlSetData($log, "Choose a Destination Folder First") EndIf $b_up = IniRead($inifile, "context", 0, 'Full') If $b_up = 'Full' Then con_men() Else con_men2() EndIf $ir = IniRead($inifile, "config", 0, 'Not Found') If $ir <> 'Not Found' Then GUICtrlSetTip($output_foler, $ir) Else GUICtrlSetTip($output_foler, "Default Output Directory") EndIf $is = IniRead($inifile, "config", 1, "") If $is = "True" Then GUICtrlSetState($b5, $GUI_CHECKED) $ws_start = True Else $ws_start = False GUICtrlSetState($b5, $GUI_UNCHECKED) EndIf load_settings() GUISetState(@SW_HIDE, $Gui) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Sleep(1000) If $tray_pop = True And $min = @MIN - 2 Then $checked = 0 For $rt = 1 To _GUICtrlListView_GetItemCount($hListView) If _GUICtrlListView_GetItemImage($hListView, $rt, 3) = 4 Then $checked += 1 Next TrayTip("OI YOU!!!", "There are " & $checked & " Items that needs you attention.", 15, 1) $min = @MIN EndIf $day_year2 = @YDAY If $day_year2 <> $day_year Then load_settings() $day_year = @YDAY EndIf WEnd ;------------------------------------------------------------------------------ Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK; Sent by a list-view control when the user clicks an item with the left mouse button Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $sel = DllStructGetData($tInfo, "SubItem") $row = DllStructGetData($tInfo, "Index") If $sel = 4 Then _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($hListView)) ElseIf $sel = 3 Then If _GUICtrlListView_GetItemImage($hListView, $row, $sel) = 3 Then _GUICtrlListView_SetItemImage($hListView, $row, 4, $sel) ElseIf _GUICtrlListView_GetItemImage($hListView, $row, $sel) = 4 Then _GUICtrlListView_SetItemImage($hListView, $row, 3, $sel) EndIf EndIf Case $LVN_GETINFOTIP, $LVN_GETINFOTIPA, $LVN_GETINFOTIPW ;Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func add_folder() If GUICtrlRead($combo1) <> 'Please Select' Then $dir = FileSelectFolder("Choose a folder.", "", 2) If Not @error Then If Not IsDeclared("sInputBoxAnswer") Then Local $sInputBoxAnswer $sInputBoxAnswer = InputBox("Name.", "Enter name for you backup.!", "", " ", "-1", "120", "-1", "-1") Select Case @error = 0;OK - The string returned is valid $i = _GUICtrlListView_AddItem($hListView, $sInputBoxAnswer, 0);name _GUICtrlListView_AddSubItem($hListView, $i, $dir, 1, -1);location _GUICtrlListView_AddSubItem($hListView, $i, GUICtrlRead($combo1), 2, -1);sheduled _GUICtrlListView_AddSubItem($hListView, $i, 'Not Done', 3, 4);backup last done _GUICtrlListView_AddSubItem($hListView, $i, '', 4, 2);delete line Case @error = 1;The Cancel button was pushed Case @error = 3;The InputBox failed to open EndSelect EndIf Else GUICtrlSetData($log, "Please Choose a Backup Schedule") EndIf EndFunc ;==>add_folder Func add_file() If GUICtrlRead($combo1) <> 'Please Select' Then $dir = FileOpenDialog("Choose a file.", @MyDocumentsDir, "") If Not @error Then $sInputBoxAnswer = InputBox("Name.", "Enter name for you backup.!", "", " ", "-1", "120", "-1", "-1") Select Case @error = 0;OK - The string returned is valid $i = _GUICtrlListView_AddItem($hListView, $sInputBoxAnswer, 1);name _GUICtrlListView_AddSubItem($hListView, $i, $dir, 1);location _GUICtrlListView_AddSubItem($hListView, $i, GUICtrlRead($combo1), 2, -1);sheduled _GUICtrlListView_AddSubItem($hListView, $i, 'Not Done', 3, 4);backup last done _GUICtrlListView_AddSubItem($hListView, $i, '', 4, 2);delete line Case @error = 1;The Cancel button was pushed Case @error = 3;The InputBox failed to open EndSelect EndIf Else GUICtrlSetData($log, "Please Choose a Backup Schedule") EndIf EndFunc ;==>add_file Func output_folder() Local $dir = FileSelectFolder("Choose a folder.", '', 1 + 4) If Not @error Then If $dir <> IniRead($inifile, "config", 0, '') Then If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(52, "Check!!!", "You Backup Directory has been changed," & @CRLF & "or a new one has been created." & @CRLF & "Is this OK.?" & @CRLF) Select Case $iMsgBoxAnswer = 6;Yes $save = $dir DirCreate($dir) IniWrite($inifile, "config", 0, $dir) GUICtrlSetTip($output_foler, $dir) GUICtrlSetState($add_file, $GUI_ENABLE) GUICtrlSetState($add_folder, $GUI_ENABLE) GUICtrlSetState($backup_now, $GUI_ENABLE) GUICtrlSetState($combo1, $GUI_ENABLE) Case $iMsgBoxAnswer = 7;No MsgBox(64, "Nothing Changed", "Nothing Has Changed, Click Ok to Continue") EndSelect EndIf EndIf EndFunc ;==>output_folder Func quit() save() GUIDelete($Gui) Exit EndFunc ;==>quit Func load_settings() _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView)) Sleep(500) $var = IniReadSection($inifile, "files") If Not @error = 1 Then For $c = 1 To $var[0][0] $ss = StringSplit($var[$c][1], "|") $i = _GUICtrlListView_AddItem($hListView, $ss[2], $ss[1]);name _GUICtrlListView_AddSubItem($hListView, $i, $ss[3], 1, -1);location _GUICtrlListView_AddSubItem($hListView, $i, $ss[4], 2, -1);sheduled $d_split_final = "" $d_split = StringSplit($ss[5], "/") If StringLen($d_split[1]) = 2 Then _ArrayReverse($d_split, 1) For $d_spl = 1 To $d_split[0] $d_split_final &= $d_split[$d_spl] & "/" Next $ss[5] = StringTrimRight($d_split_final, 1) $dd = _DateDiff('d', $ss[5] & " 00:00:00", _NowCalc()) $d_split_final = "" $d_split = StringSplit($ss[5], "/") _ArrayReverse($d_split, 1) For $d_spl = 1 To $d_split[0] $d_split_final &= $d_split[$d_spl] & "/" Next $ss[5] = StringTrimRight($d_split_final, 1) Else $dd = _DateDiff('d', $ss[5] & " 00:00:00", _NowCalc()) $d_split = StringSplit($ss[5], "/") _ArrayReverse($d_split, 1) For $d_spl = 1 To $d_split[0] $d_split_final &= $d_split[$d_spl] & "/" Next $ss[5] = StringTrimRight($d_split_final, 1) EndIf If $ss[5] <> 'Not Done' Then If $ss[4] = 'Daily' And $dd > 0 Then $tray_pop = True _GUICtrlListView_AddSubItem($hListView, $i, $ss[5], 3, 4);backup last done ElseIf $ss[4] = 'Weekly' And $dd > 6 Then _GUICtrlListView_AddSubItem($hListView, $i, $ss[5], 3, 4) $tray_pop = True ElseIf $ss[4] = 'Monthly' And $dd > 30 Then _GUICtrlListView_AddSubItem($hListView, $i, $ss[5], 3, 4) $tray_pop = True Else _GUICtrlListView_AddSubItem($hListView, $i, $ss[5], 3, 3) EndIf Else _GUICtrlListView_AddSubItem($hListView, $i, $ss[5], 3, 4) $tray_pop = True EndIf _GUICtrlListView_AddSubItem($hListView, $i, '', 4, 2);delete line Next If $tray_pop = True Then $checked = 0 For $rt = 1 To _GUICtrlListView_GetItemCount($hListView) If _GUICtrlListView_GetItemImage($hListView, $rt, 3) = 4 Then $checked += 1 Next TrayTip("OI YOU!!!", "There are " & $checked & " Items that needs you attention.", 15, 1) EndIf EndIf EndFunc ;==>load_settings Func backup_now() ;_GuiCtrlListView_SetItemState ($hListView, 0, $LVIS_selected, $LVIS_selected) ;_GuiCtrlListView_SetItemSelected ($hListView,0) GUICtrlSetImage($backup_now, 'shell32.dll', 200) $tray_pop = False GUICtrlSetData($log, "WORKING!!!!") GUICtrlSetBkColor($progress, 0xFF0000) GUICtrlSetData($progress, 0) $t = _GUICtrlListView_GetItemCount($hListView) - 1 For $xct = 0 To $t _GUICtrlListView_SetItemSelected($hListView, $xct,1,1) If $xct > 0 Then _GUICtrlListView_SetItemSelected($hListView, $xct - 1, 0) EndIf ;---------------Partial-------------------------------------------- If _GUICtrlListView_GetItemImage($hListView, $xct, 3) = 4 Then If _GUICtrlListView_GetItemImage($hListView, $xct, 0) = 0 Then $ss2 = StringSplit(_GUICtrlListView_GetItemText($hListView, $xct, 1), "\") GUICtrlSetBkColor($progress2, 0xFF0000) GUICtrlSetData($progress2, 0) _DirCopy(_GUICtrlListView_GetItemText($hListView, $xct, 1), $ir & "\" & $ss2[$ss2[0]], 1) GUICtrlSetBkColor($progress2, 0x00ff00) If $_dir_copy = 0 Then _GUICtrlListView_SetItemImage($hListView, $xct, 3, 3) _GUICtrlListView_SetItemText($hListView, $xct, _NowDate(), 3) Else _GUICtrlListView_SetItemText($hListView, $xct, "Failed", 3) EndIf Else If FileCopy(_GUICtrlListView_GetItemText($hListView, $xct, 1), $ir, 1) = 1 Then _GUICtrlListView_SetItemImage($hListView, $xct, 3, 3) _GUICtrlListView_SetItemText($hListView, $xct, _NowDate(), 3) Else _GUICtrlListView_SetItemText($hListView, $xct, "Failed", 3) EndIf EndIf ;-------------------------------FULL-------------------------------------- ElseIf _GUICtrlListView_GetItemImage($hListView, $xct, 3) = 3 And $b_up = 'Full' Then If _GUICtrlListView_GetItemImage($hListView, $xct, 0) = 0 Then $ss2 = StringSplit(_GUICtrlListView_GetItemText($hListView, $xct, 1), "\") GUICtrlSetBkColor($progress2, 0xFF0000) GUICtrlSetData($progress2, 0) _DirCopy(_GUICtrlListView_GetItemText($hListView, $xct, 1), $ir & "\" & $ss2[$ss2[0]], 1) GUICtrlSetBkColor($progress2, 0x00ff00) If $_dir_copy = 0 Then _GUICtrlListView_SetItemImage($hListView, $xct, 3, 3) _GUICtrlListView_SetItemText($hListView, $xct, _NowDate(), 3) Else _GUICtrlListView_SetItemText($hListView, $xct, "Failed", 3) EndIf Else If FileCopy(_GUICtrlListView_GetItemText($hListView, $xct, 1), $ir, 1) = 1 Then _GUICtrlListView_SetItemImage($hListView, $xct, 3, 3) _GUICtrlListView_SetItemText($hListView, $xct, _NowDate(), 3) Else _GUICtrlListView_SetItemText($hListView, $xct, "Failed", 3) EndIf EndIf EndIf GUICtrlSetData($progress, (($xct + 1) / ($t + 1)) * 100) Sleep(100) If $xct = $t Then _GUICtrlListView_SetItemSelected($hListView, $xct, 0) EndIf Next GUICtrlSetColor($progress, 0x00FF00) GUICtrlSetData($log, "Done.") GUICtrlSetImage($backup_now, "shell32.dll", 7) save() EndFunc ;==>backup_now Func HideShow() If $Tray[0] = 0 Then $Tray[0] = 1 GUISetState(@SW_HIDE, $Gui) TraySetToolTip("Left Click to Show/Hide Window") ElseIf $Tray[0] = 1 Then $Tray[0] = 0 GUISetState(@SW_SHOW, $Gui) TraySetToolTip("Left Click to Show/Hide Window") EndIf EndFunc ;==>HideShow Func con_men() GUICtrlSetState($b2, $GUI_CHECKED) GUICtrlSetState($b3, $GUI_UNCHECKED) $b_up = 'Full' IniWrite($inifile, "context", 0, 'Full') EndFunc ;==>con_men Func con_men2() GUICtrlSetState($b2, $GUI_UNCHECKED) GUICtrlSetState($b3, $GUI_CHECKED) $b_up = 'Part' IniWrite($inifile, "context", 0, 'Part') EndFunc ;==>con_men2 Func windows_start() If $ws_start = False Then $ws_start = True GUICtrlSetState($b5, $GUI_CHECKED) $a = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Daily Backupv1_3b") ;if it doesn't write it If @error = -1 Then ConsoleWrite("attempting Regwrite " & $a & @LF) If RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Daily Backupv1_3b", "REG_SZ", @ScriptDir & "\Daily Backupv1_3b.exe") <> 1 Then If @error = 1 Then MsgBox(0, "Error", "Unable to save to requested key", 2) ElseIf @error = 2 Then MsgBox(0, "Error", "unable to save main key.", 2) ElseIf @error = 3 Then MsgBox("Error", "Unable to remote connect to the registry", 2) ElseIf @error = -1 Then MsgBox("Error", "Unable to save requested value", 2) ElseIf @error = -2 Then MsgBox("Error", "Value type not supported,", 2) EndIf EndIf EndIf ElseIf $ws_start = True Then $ws_start = False GUICtrlSetState($b5, $GUI_UNCHECKED) ConsoleWrite("Attempting reg delete" & @LF) If RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Daily Backupv1_3b") <> 1 Then If @error = 1 Then MsgBox(0, "Error", "Unable to open requested key", 2) ElseIf @error = 2 Then MsgBox(0, "Error", " deleting key/value.", 2) ElseIf @error = 3 Then MsgBox("Error", "Unable to remote connect to the registry", 2) ElseIf @error = -1 Then MsgBox("Error", "Unable to delete requested value", 2) ElseIf @error = -2 Then MsgBox("Error", "Unable to delete requested key/value", 2) EndIf EndIf EndIf IniWrite($inifile, "config", 1, $ws_start) EndFunc ;==>windows_start Func _DirCopy($iSource, $iDest, $flag = 1);$flag = 1 - Overwrite files and folders $_dir_copy = 0 Dim $aFiles[1] Local $iFirstFile, $iNextFile, $iFullFile, $iRec = '' Local $iFirstFile = FileFindFirstFile($iSource & "\*.*") If @error Then Return While 1 $iNextFile = FileFindNextFile($iFirstFile) If @error Then Local $iPercent, $iDestDir, $oFile, $oFolder, $i $oFile = 9 $oFolder = 1 If Not FileExists($iDest) Then DirCreate($iDest) For $i = 1 To $aFiles[0] $iPercent = Round($i / $aFiles[0] * 100, 2) GUICtrlSetData($progress2, $iPercent) If StringInStr(FileGetAttrib($aFiles[$i]), "D") Then $iDestDir = $iDest & "\" & StringRegExpReplace($aFiles[$i], "^.*\\", "") If Not FileExists($iDestDir) Then DirCreate($iDestDir) If DirCopy($aFiles[$i], $iDestDir, $oFolder) <> 1 Then $_dir_copy += 1 Else If FileCopy($aFiles[$i], $iDest, $oFile) <> 1 Then $_dir_copy += 1 EndIf Next ExitLoop EndIf $iFullFile = $iSource & "\" & $iNextFile $aFiles[0] += 1 ReDim $aFiles[$aFiles[0] + 1] $aFiles[$aFiles[0]] = $iFullFile WEnd FileClose($iFirstFile) EndFunc ;==>_DirCopy Func save() $ct = _GUICtrlListView_GetItemCount($hListView) If $ct > 0 Then IniDelete($inifile, "files") For $x = 0 To $ct - 1 IniWrite($inifile, "files", $x, _GUICtrlListView_GetItemImage($hListView, $x) & "|" & _ _GUICtrlListView_GetItemText($hListView, $x, 0) & "|" & _ _GUICtrlListView_GetItemText($hListView, $x, 1) & "|" & _ _GUICtrlListView_GetItemText($hListView, $x, 2) & "|" & _ _GUICtrlListView_GetItemText($hListView, $x, 3)) Next Else IniDelete($inifile, "files") EndIf IniWrite($inifile, "config", 1, $ws_start) $win_pos = WinGetPos("My Backup V1.3") IniWrite($inifile, "winpos", 0, Round($win_pos[0], -1) & "|" & Round($win_pos[1], -1) & "|" & '500' & "|" & Round($win_pos[3] - 10, -1)) EndFunc ;==>save [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
Fran Posted July 8, 2010 Share Posted July 8, 2010 when it starts to copy (only large files) sometimes it stops respondingHave you had any luck with this problem? My gui does the same and it irritates me tremendously!F Link to comment Share on other sites More sharing options...
wraithdu Posted July 8, 2010 Share Posted July 8, 2010 Talk about a dead topic... There is no solution. The cause is AutoIt's single threaded nature. Since the copy process takes so long for large files, AutoIt is not responding to OS messages sent to its GUI window, and Windows therefore things the app is hung. You can't get around it unless you move the copy operation into another thread (good luck). You could try copying files via COM with Shell.Application or Scripting.FileSystemObject, but I don't know if you'll have any better luck. Link to comment Share on other sites More sharing options...
wraithdu Posted July 8, 2010 Share Posted July 8, 2010 Sorry, the two object methods suffer the same problem. Link to comment Share on other sites More sharing options...
wraithdu Posted July 8, 2010 Share Posted July 8, 2010 Because I'm a nice guy:HERE Link to comment Share on other sites More sharing options...
Authenticity Posted July 8, 2010 Share Posted July 8, 2010 WriteFile and ReadFile API functions are synchronized functions. They don't return control to the executing thread while they're executed. For that reason there is WriteFileEx and ReadFileEx, to do asynchronous device operations. It isn't correct for an application that depends on the completion to continue code execution as it's idle. If you want to be able to handle controls events, or to be responsive in general, you should call ReadFileEx from an adlib function and write using WriteFileEx from the callback user-defind function. Still, you should disable (gray-out) controls, or develop an approach that would not interfere with the device I/O operations. Link to comment Share on other sites More sharing options...
wraithdu Posted July 8, 2010 Share Posted July 8, 2010 The problem with ReadFileEx and WriteFileEx in the context of copying a file, is that you don't want to or can't allocate a memory buffer to hold a 1GB, 2GB, whatever GB file from ReadFileEx, to then WriteFileEx the copy. You'd want to do this in chunks. Now you've got two asynchronous procedure calls which you have to synchronize and coordinate. That's just a headache. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now