Aceguy Posted March 21, 2008 Share Posted March 21, 2008 make some items then click them in order. expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\Icon Entry_573.ico #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiListView.au3> #include <GuiImageList.au3> #include <GuiConstantsEx.au3> #include <GuiComboBox.au3> #include <Date.au3> $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 Global $Gui, $GuiContext[2], $Tray[2] $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.1", 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, 15, 175, 25) GUICtrlSetResizing(-1,$GUI_DOCKALL) $progress = GUICtrlCreateProgress(210, 40, 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) $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_SUBITEMIMAGES, $LVS_EX_FULLROWSELECT,$LVS_EX_DOUBLEBUFFER )) _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) 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,'false') if $is = "True" Then GUICtrlSetState($b5,$GUI_CHECKED) $ws_start=True Else $ws_start=False 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 TrayTip("OI YOU!!!", "My Backup Needs Your 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_DeleteItem($hListView, $row) 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 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() $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 If $ws_start=True Then $a = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 'Daily Backup') ;if it doesn't write it If @error = -1 Then $b = RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 'Daily Backup', "REG_SZ", @ScriptDir & "\Daily Backup.exe") If $b = 1 Then MsgBox(0, "Success", "Programm automated successfully", 2) Else MsgBox(0, "Error", "An Error occured while writing", 2) EndIf EndIf Elseif $ws_start=False Then if RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 'Daily Backup') <> 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) $win_pos=WinGetPos("My Backup V1.1") IniWrite($inifile,"winpos",0,round($win_pos[0],-1)&"|"&round($win_pos[1],-1)&"|"&'500'&"|"&round($win_pos[3]-10,-1)) GUIDelete($Gui) Exit EndFunc ;==>quit Func load_settings() _GUICtrlListView_DeleteAllItems($hListView) $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 $dd = _DateDiff('d', $ss[5] & " 00:00:00", _NowCalc()) 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 TrayTip("OI YOU!!!", "My Backup Needs Your Attention", 15, 1) EndIf EndFunc ;==>load_settings Func backup_now() ;_GuiCtrlListView_SetItemState ($hListView, 0, $LVIS_selected, $LVIS_selected) ;_GuiCtrlListView_SetItemSelected ($hListView,0) $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) 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), "\") If DirCopy(_GUICtrlListView_GetItemText($hListView, $xct, 1), $ir & "\" & $ss2[$ss2[0]], 1) = 1 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), "\") If DirCopy(_GUICtrlListView_GetItemText($hListView, $xct, 1), $ir & "\" & $ss2[$ss2[0]], 1) = 1 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(250) If $xct = $t Then _GUICtrlListView_SetItemSelected($hListView, $xct, 0) EndIf Next GUICtrlSetColor($progress, 0x00FF00) GUICtrlSetData($log, "") 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 Func windows_start() if GUICtrlRead($b5) = 68 Then GUICtrlSetState($b5,$GUI_CHECKED) $ws_start=True Else $ws_start=False GUICtrlSetState($b5,$GUI_UNCHECKED) EndIf ConsoleWrite($ws_start&@LF) EndFunc ;==>windows_start [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...
GaryFrost Posted March 21, 2008 Share Posted March 21, 2008 http://www.autoitscript.com/forum/index.php?showtopic=59685 SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Kerros Posted March 21, 2008 Share Posted March 21, 2008 I started playing around with your script(looks nice by the way), and I did notice where the GUI would hide if you clicked on the last entry after clicking on any other entry. I placed #AutoIt3Wrapper_run_debug_mode=Y in the AutoIT3Wrapper section and while looking through the debug items it does appear that the script is telling the GUI to hide from line 455. If I comment that line out the GUI does not hide. It also doesn't hide when you tell it to, but that I can understand as I'm messing up the entire function. Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
Aceguy Posted March 22, 2008 Author Share Posted March 22, 2008 (edited) thanks, its all sorted. GaryFrost your a Genius. i want to add another progress bar to show the files in the folders being copied..... HMMM.... not sure i can do that 1. Dircopy is a single proccess and its state will either 1 or 0? (working or not) but will try for V1.2, but if you guys could help Edited March 22, 2008 by Aceguy [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...
Aceguy Posted March 22, 2008 Author Share Posted March 22, 2008 i have found this doing a search but the only one whic sorta worked was expandcollapse popupGlobal $aFiles[1] _DirCopy("d:\download", "c:\wallpaper", 1) Func _DirCopy($iSource, $iDest, $flag = 1);$flag = 1 - Overwrite files and folders 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 If $flag > 0 Then $oFile = 9 $oFolder = 1 Else $oFile = 0 $oFolder = 0 EndIf If Not FileExists($iDest) Then DirCreate($iDest) ProgressOn("Copy", "File: ", "", -1, -1, 16) For $i = 1 To $aFiles[0] $iPercent = Round($i / $aFiles[0] * 100, 2) ProgressSet($iPercent, $aFiles[$i] & " copyed", $iPercent & "% done") If StringInStr(FileGetAttrib($aFiles[$i]), "D") Then $iDestDir = $iDest &"\"& StringRegExpReplace($aFiles[$i], "^.*\\", "") If Not FileExists($iDestDir) Then DirCreate($iDestDir) DirCopy($aFiles[$i], $iDestDir, $oFolder) Else FileCopy($aFiles[$i], $iDest, $oFile) EndIf Next ProgressSet(100, "Done", "Complete") Sleep(1000) ProgressOff() ExitLoop EndIf $iFullFile = $iSource &"\"& $iNextFile $aFiles[0] += 1 ReDim $aFiles[$aFiles[0] + 1] $aFiles[$aFiles[0]] = $iFullFile WEnd FileClose($iFirstFile) EndFunc But it copies all the required files and duplicates them to all the folders, so i end up with 6 copies of the same files and folders. [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...
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