Jump to content



Photo

Help needed on GUICtrlTreeView_Create()


  • Please log in to reply
18 replies to this topic

#1 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 08 June 2012 - 11:29 PM

Hi All,
I am creating a tool using the example of GUICtrlTreeView_Create() function and Melba's _RecFileListArray() function. I need to make one thing on below example. Like, there will be lot of nodes in tree view. some of the parent node will have child nodes. what i wanted is when i check the parent node automatically all the child nodes should be unchecked it should happen in the same wise versa... any suggestion for me ?

AutoIt         
#include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> #include "RecFileListToArray.au3" $Debug_TV = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work Global $hTreeView _Main() Func _Main() Local $GUI, $hItem Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) $GUI = GUICreate("(UDF Created) TreeView Create", 400, 300) $hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState() ;GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _GUICtrlTreeView_BeginUpdate($hTreeView) $aArray = _RecFileListToArray("C:\") $hItem = _GUICtrlTreeView_Add($hTreeView, 0, "C:") For $x = 1 To UBound($aArray) -1 ; For $y = 1 To Random(2, 10, 1) $So = _GUICtrlTreeView_AddChild($hTreeView, $hItem, $aArray[$x]) $Laray =  _RecFileListToArray("C:\"&$aArray[$x]) For $Y = 1 To UBound($Laray) -1 _GUICtrlTreeView_AddChild($hTreeView, $So, $Laray[$Y]) Next ; Next Next _GUICtrlTreeView_EndUpdate($hTreeView) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc   ;==>_Main

Thank you,Regards,K.Syed Ibrahim.





#2 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,318 posts

Posted 09 June 2012 - 06:41 AM

Syed23,

I did this a while ago in this thread. The examples get more complex as you move through the thread. ;)

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#3 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 09 June 2012 - 11:19 AM

Syed23,

I did this a while ago in this thread. The examples get more complex as you move through the thread. ;)

M23

Thanks for your quick reply Melba23. As always your awesome! what i wanted is without using buttons, if i select the parent node it should select the child nodes.. if select any one child node the parent node should shows as semi selected. is there a possibility to do that ?
Thank you,Regards,K.Syed Ibrahim.

#4 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,318 posts

Posted 09 June 2012 - 05:03 PM

Syed23,

So what have you tried that has not worked as you wish? ;)

I am not doing all the work for you. The scripts in the thread to which I linked show you how you might go about it - so let us see some effort from you. :)

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#5 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 09 June 2012 - 07:23 PM

Syed23,

So what have you tried that has not worked as you wish? ;)

I am not doing all the work for you. The scripts in the thread to which I linked show you how you might go about it - so let us see some effort from you. :)

M23


Really i am happy to see some straight forward reply :) i am working on it right now. soon i will come up with the result to you for some modifications to my code ;)

Edited by Syed23, 09 June 2012 - 07:23 PM.

Thank you,Regards,K.Syed Ibrahim.

#6 zamboni128

zamboni128

    Seeker

  • Active Members
  • 15 posts

Posted 16 June 2012 - 02:09 AM

I have been working on a project that required a treeview list. I'm all most finished but will attach what I have so far. I think it will work for you. The piece I'm missing is I want to be able to click on the text next to the checkbox and it work as if I clicked in the checkbox. If anybody has the answer, I would be grateful.

Let me know if this helps.

Attached Files



#7 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 07 August 2012 - 03:01 PM

Syed23,

So what have you tried that has not worked as you wish? Posted Image

I am not doing all the work for you. The scripts in the thread to which I linked show you how you might go about it - so let us see some effort from you. Posted Image

M23

Hi Melba23,
Please find the code below which i have started as begining. I am breaking my head to make this code work atleast but no clue why it is not working :'(. can you help me please?

AutoIt         
#include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> #include "RecFileListToArray.au3" #include"Array.au3" $Debug_TV = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work Global $fDblClk = False Global $hTreeView, $hItem,$x ,$hWnd,$z,$hLastSelected,$aItems,$hTV,$iSelectedIndex Global $aItems[17][3] _Main() Func _Main() Local $GUI, $hItem Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES ) $GUI = GUICreate("(UDF Created) TreeView Create", 400, 300) $hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) ;  $hTV = GUICtrlGetHandle(-1) GUISetState() ;GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _GUICtrlTreeView_BeginUpdate($hTreeView) $aArray = _RecFileListToArray("C:") $hItem = _GUICtrlTreeView_Add($hTreeView, 0, "C:") _GUICtrlTreeView_SetState($hTreeView, $hItem, $TVIS_EXPANDED) For $x = 1 To UBound($aArray) - 1 ; For $y = 1 To Random(2, 10, 1) $So = _GUICtrlTreeView_AddChild($hTreeView, $hItem, $aArray[$x]) $Laray = _RecFileListToArray("C:" & $aArray[$x]) For $Y = 1 To UBound($Laray) - 1 _GUICtrlTreeView_AddChild($hTreeView, $So, $Laray[$Y]) Next ; Next Next _GUICtrlTreeView_EndUpdate($hTreeView) ; Loop until user exits While 1     Switch GUIGetMsg()         Case $GUI_EVENT_CLOSE             Exit     EndSwitch If $fDblClk = True Then         $sText = _GUICtrlTreeView_GetText($hTreeView, _GUICtrlTreeView_GetSelection($hTreeView))      ;   _SetTheData($sText)         MsgBox(0,"",$sText)     EndIf   WEnd EndFunc Func MY_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)     Switch $wParam         Case $hTreeView             Local $tagNMHDR = DllStructCreate("int;int;int", $lParam)             If @error Then Return             If DllStructGetData($tagNMHDR, 3) = $NM_CLICK Then $fDblClk = True     EndSwitch EndFunc  ;==>MY_WM_NOTIFY

Thank you,Regards,K.Syed Ibrahim.

#8 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,318 posts

Posted 07 August 2012 - 08:41 PM

Syed23,

You need to ask the UDF to return a sorted file/folder array and then parse it to get the folder tree to be displayed in the proper format. At the moment you are just adding every element as a new item. ;)

Take a look at my ChooseFileFolder UDF - the _CFF_TV_Fill function shows how I did it. You should examine the code following "Case 0 ; Folders and matching files" - and in particular the code where the "default folder array" is NOT set (i.e. after the Else statements and using the _CFF_ListFiles function). It shows how I first list the folders to act as nodes and then add the files as items under the relevant node. The code is pretty well commented, so I hope you can follow it - please ask if not. :)

One word of warning. I see you are looking to list the whole C: drive - that is going to be seriously slow. You might need to look for another solution - perhaps Yashied's TV Explorer UDF might be a better start point. ;)

M23

Edited by Melba23, 07 August 2012 - 09:01 PM.
Added more detail

StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#9 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,318 posts

Posted 08 August 2012 - 04:31 PM

Syed23,

Here is an example of how you might do it using the AutoIt folder: :)
AutoIt         
#include <GUIConstantsEx.au3> #include <TreeviewConstants.au3> #include <RecFileListToArray.au3> $sAutoIt_Dir = StringReplace(@AutoItExe, "autoit3.exe","") $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0xC4C4C4) $cTV = GUICtrlCreateTreeView(10, 10, 480, 480, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)) $cRoot = GUICtrlCreateTreeViewItem($sAutoIt_Dir, $cTV) GUISetState() _Fill_TV($cRoot, $sAutoIt_Dir, "*.*") While 1     Switch GUIGetMsg()         Case $GUI_EVENT_CLOSE             Exit     EndSwitch WEnd Func _Fill_TV($cTV, $sRoot, $sFile_Mask)     Local $aLevel[100] = [$cTV], $iLevel, $aFolders, $sFullFolderpath, $sFolderName     ; Add root files     _Add_Files($sAutoIt_Dir, "*.*", $aLevel[0])     ; List folders     $aFolders = _RecFileListToArray($sAutoIt_Dir, "*", 2, 1, 1, 1)     ; Add folders     For $i = 1 To $aFolders[0]         $sFullFolderpath = $aFolders[$i]         ; Count         StringRegExpReplace($sFullFolderpath, "", "")         $iLevel = @extended         ; Extract folder name from path         $sFolderName = StringRegExpReplace($sFullFolderpath, "(.*|^)(.*)", "$2")         ; Add to TV and store item ControlID         $aLevel[$iLevel] = GUICtrlCreateTreeViewItem($sFolderName, $aLevel[$iLevel - 1])         ; Add files within folder         _Add_Files($sRoot & $aFolders[$i], $sFile_Mask, $aLevel[$iLevel])     Next EndFunc Func _Add_Files($sFolderPath, $sFile_Mask, $hTreeView_Parent)     ; List files     Local $aFileArray = _RecFileListToArray($sFolderPath, $sFile_Mask, 1, 0, 1, 0)     ; Add files to TreeView     If IsArray($aFileArray) Then         For $j = 1 To $aFileArray[0]             GUICtrlCreateTreeViewItem($aFileArray[$j], $hTreeView_Parent)         Next     EndIf EndFunc   ;==>_Add_Files

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#10 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 09 August 2012 - 08:17 AM

Syed23,

Here is an example of how you might do it using the AutoIt folder: :)

AutoIt         
#include <GUIConstantsEx.au3> #include <TreeviewConstants.au3> #include <RecFileListToArray.au3> $sAutoIt_Dir = StringReplace(@AutoItExe, "autoit3.exe","") $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0xC4C4C4) $cTV = GUICtrlCreateTreeView(10, 10, 480, 480, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)) $cRoot = GUICtrlCreateTreeViewItem($sAutoIt_Dir, $cTV) GUISetState() _Fill_TV($cRoot, $sAutoIt_Dir, "*.*") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Fill_TV($cTV, $sRoot, $sFile_Mask) Local $aLevel[100] = [$cTV], $iLevel, $aFolders, $sFullFolderpath, $sFolderName ; Add root files _Add_Files($sAutoIt_Dir, "*.*", $aLevel[0]) ; List folders $aFolders = _RecFileListToArray($sAutoIt_Dir, "*", 2, 1, 1, 1) ; Add folders For $i = 1 To $aFolders[0] $sFullFolderpath = $aFolders[$i] ; Count StringRegExpReplace($sFullFolderpath, "", "") $iLevel = @extended ; Extract folder name from path $sFolderName = StringRegExpReplace($sFullFolderpath, "(.*|^)(.*)", "$2") ; Add to TV and store item ControlID $aLevel[$iLevel] = GUICtrlCreateTreeViewItem($sFolderName, $aLevel[$iLevel - 1]) ; Add files within folder _Add_Files($sRoot & $aFolders[$i], $sFile_Mask, $aLevel[$iLevel]) Next EndFunc Func _Add_Files($sFolderPath, $sFile_Mask, $hTreeView_Parent) ; List files Local $aFileArray = _RecFileListToArray($sFolderPath, $sFile_Mask, 1, 0, 1, 0) ; Add files to TreeView If IsArray($aFileArray) Then For $j = 1 To $aFileArray[0] GUICtrlCreateTreeViewItem($aFileArray[$j], $hTreeView_Parent) Next EndIf EndFunc ;==>_Add_Files
M23

wow...this is awesome! you are great as always! sure this is going to be very useful one for my upcoming project, but before that i should understand what happens :D

i have integrated the code of Zamboni128 to my project.
|amboni128 - sorry for using your code without your permission :( please allow me to use your code and i will try to understand it!

Melba23 - just curious, i have selected the some items in treeview, now i wanted to read the selected items, like only one file selected in folder or entire folder has been selected? based on that i would like to read the hierarchy... is that possible to do ?anysuggestion for me how to start that ? yesterday i tried by using _Guictrltreeview_Gettext(),_Guictrltreeview_Getparenthandler(), nothing works out for me :'(

Edited by Syed23, 09 August 2012 - 08:18 AM.

Thank you,Regards,K.Syed Ibrahim.

#11 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,318 posts

Posted 09 August 2012 - 07:57 PM

Syed23,

That was fun and I learn a lot about TreeViews! :D

This should do what you want - the checkboxes check/uncheck correctly for parent/child selections and pressing the "Read" button lists the checked items: :)
AutoIt         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeview.au3> #include <WinAPI.au3> #include <RecFileListToArray.au3> #include <Array.au3> Global $aFolderItem[1] = [0], $aFileItem[1] = [0] $sAutoIt_Dir = StringReplace(@AutoItExe, "autoit3.exe","") $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0xC4C4C4) $cTV = GUICtrlCreateTreeView(10, 10, 480, 380, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)) $cRoot = GUICtrlCreateTreeViewItem($sAutoIt_Dir, $cTV) $cButton = GUICtrlCreateButton("Read", 10, 400, 80, 30) $cPossUncheck = GUICtrlCreateDummy() GUISetState() _Fill_TV($cRoot, $sAutoIt_Dir, "*.*") GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1     Switch GUIGetMsg()         Case $GUI_EVENT_CLOSE             Exit         Case $cButton             ConsoleWrite("----------------------------" & @CRLF)             For $i = 1 To $aFolderItem[0]                 If _GUICtrlTreeView_GetChecked($cTV, $aFolderItem[$i]) Then                     ConsoleWrite(_GUICtrlTreeView_GetText($cTV, $aFolderItem[$i]) & " is checked" & @CRLF)                 EndIf             Next             For $i = 1 To $aFileItem[0]                 If _GUICtrlTreeView_GetChecked($cTV, $aFileItem[$i]) Then                     ConsoleWrite(_GUICtrlTreeView_GetText($cTV, $aFileItem[$i]) & " is checked" & @CRLF)                 EndIf             Next         Case $cPossUncheck             _PossUncheck_Parents(GUICtrlRead($cPossUncheck))     EndSwitch WEnd Func _Fill_TV($cTV, $sRoot, $sFile_Mask)     Local $aLevel[100] = [$cTV], $iLevel, $aFolders, $sFullFolderpath, $sFolderName     ; Add root files     _Add_Files($sAutoIt_Dir, "*.*", $aLevel[0])     ; List folders     $aFolders = _RecFileListToArray($sAutoIt_Dir, "*", 2, 1, 1, 1)     ; Add folders     For $i = 1 To $aFolders[0]         $sFullFolderpath = $aFolders[$i]         ; Count         StringRegExpReplace($sFullFolderpath, "", "")         $iLevel = @extended         ; Extract folder name from path         $sFolderName = StringRegExpReplace($sFullFolderpath, "(.*|^)(.*)", "$2")         ; Add to TV and store item ControlID         $aLevel[$iLevel] = GUICtrlCreateTreeViewItem($sFolderName, $aLevel[$iLevel - 1])         $aFolderItem[0] += 1         If UBound($aFolderItem) = $aFolderItem[0] Then ReDim $aFolderItem[$aFolderItem[0] * 2]         $aFolderItem[$aFolderItem[0]] = $aLevel[$iLevel]         ; Add files within folder         _Add_Files($sRoot & $aFolders[$i], $sFile_Mask, $aLevel[$iLevel])     Next     ; ReDim arrays to correct size     ReDim $aFolderItem[$aFolderItem[0] + 1]     ReDim $aFileItem[$aFileItem[0] + 1] EndFunc Func _Add_Files($sFolderPath, $sFile_Mask, $hTreeView_Parent)     ; List files     Local $aFileArray = _RecFileListToArray($sFolderPath, $sFile_Mask, 1, 0, 1, 0)     ; Add files to TreeView     If IsArray($aFileArray) Then         For $j = 1 To $aFileArray[0]             $aFileItem[0] += 1             If UBound($aFileItem) = $aFileItem[0] Then ReDim $aFileItem[$aFileItem[0] * 2]             $aFileItem[$aFileItem[0]] = GUICtrlCreateTreeViewItem($aFileArray[$j], $hTreeView_Parent)             Next     EndIf EndFunc   ;==>_Add_Files Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)     Local $cCID = BitAnd($wParam, 0x0000FFFF) ; ControlID     Local $tStruct = DllStructCreate("dword;int;int", $lParam)     Switch DllStructGetData($tStruct, 3) ; Code         Case $NM_CLICK, $TVN_KEYDOWN             Local $tMousePos = _WinAPI_GetMousePos(True, DllStructGetData($tStruct, 1)) ; HWndFrom             Switch _GUICtrlTreeView_HitTest($cCID, DllStructGetData($tMousePos, 1), DllStructGetData($tMousePos, 2))                 Case 64                     $cTVItem = _GUICtrlTreeView_HitTestItem($cCID, DllStructGetData($tMousePos, 1), DllStructGetData($tMousePos, 2))                     $sText = _GUICtrlTreeView_GetText($cTV, $cTVItem)                     ; Is it a node                     If _GUICtrlTreeView_GetChildren($cTV, $cTVItem) Then                         ; Check/uncheck the children as required                         If _GUICtrlTreeView_GetChecked($cTV, $cTVItem) Then                             _CheckUncheck_Children($cTVItem, False)                         Else                             _CheckUncheck_Children($cTVItem, True)                             ; And go back up the tree to see if parents need to be checked as well                             _Check_Parents($cTVItem)                         EndIf                     Else                         ; If child unchecked, check if parents need unchecking                         If _GUICtrlTreeView_GetChecked($cTV, $cTVItem) Then                             ; We need to do this as the TreeView must clear the check before we check                             GUICtrlSendToDummy($cPossUncheck, $cTVItem)                         Else                             ; Check parents up the line                             _Check_Parents($cTVItem)                         EndIf                     EndIf             EndSwitch     EndSwitch     Return $GUI_RUNDEFMSG EndFunc Func _PossUncheck_Parents($hHandle)     ; Get the handle of the parent     $hParent = _GUICtrlTreeView_GetParentHandle($cTV, $hHandle)     ; If there is no parent     If $hParent = 0 Then         Return     EndIf     ; Set flag     Local $fAll_Unchecked = True     ; Run through all children to see if any checked     ; Get the handle of the first child     $hChild = _GUICtrlTreeView_GetFirstChild($cTV, $hParent)     ; If there is no child     If $hChild = 0 Then         Return     EndIf     ; Is child checked     If _GUICtrlTreeView_GetChecked($cTV, $hChild) Then         ; Clear flag         $fAll_Unchecked = False     Else         ; Now look for all children         While 1             ; Look for next child             $hChild = _GUICtrlTreeView_GetNextChild($cTV, $hChild)             ; Exit the loop if none found             If $hChild = 0 Then                 ExitLoop             EndIf             ; Is child checked             If _GUICtrlTreeView_GetChecked($cTV, $hChild) Then                 ; Clear flag                 $fAll_Unchecked = False                 ExitLoop             EndIf         WEnd     EndIf     ; If all checked than uncheck - or check if not     If $fAll_Unchecked Then         _GUICtrlTreeView_SetChecked($cTV, $hParent, False)     Else         _GUICtrlTreeView_SetChecked($cTV, $hParent, True)     EndIf     ; Now look further up the tree     _PossUncheck_Parents($hParent) EndFunc Func _Check_Parents($hHandle)     ; Get the handle of the parent     $hParent = _GUICtrlTreeView_GetParentHandle($cTV, $hHandle)     ; If there is no parent     If $hParent = 0 Then         Return     EndIf     ; Check the parent     _GUICtrlTreeView_SetChecked($cTV, $hParent)     ; And look for the grandparent and so on     _Check_Parents($hParent) EndFunc Func _CheckUncheck_Children($hHandle, $fState)     ; Get the handle of the first child     $hChild = _GUICtrlTreeView_GetFirstChild($cTV, $hHandle)     ; If there is no child     If $hChild = 0 Then         Return     EndIf     ; Check/Uncheck the child     _GUICtrlTreeView_SetChecked($cTV, $hChild, $fState)     _CheckUncheck_Children($hChild, $fState)     ; Now look for all grandchildren     While 1         ; Look for next child         $hChild = _GUICtrlTreeView_GetNextChild($cTV, $hChild)         ; Exit the loop if none found         If $hChild = 0 Then             ExitLoop         EndIf         ; Uncheck the child         _GUICtrlTreeView_SetChecked($cTV, $hChild, $fState)         ; Check for children         _CheckUncheck_Children($hChild, $fState)         ; And then look for the next child     WEnd EndFunc

Let me know if it is not quite right. :)

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#12 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 23 August 2012 - 12:44 PM

Syed23,

That was fun and I learn a lot about TreeViews! :D

This should do what you want - the checkboxes check/uncheck correctly for parent/child selections and pressing the "Read" button lists the checked items: :)

AutoIt         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeview.au3> #include <WinAPI.au3> #include <RecFileListToArray.au3> #include <Array.au3> Global $aFolderItem[1] = [0], $aFileItem[1] = [0] $sAutoIt_Dir = StringReplace(@AutoItExe, "autoit3.exe","") $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0xC4C4C4) $cTV = GUICtrlCreateTreeView(10, 10, 480, 380, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)) $cRoot = GUICtrlCreateTreeViewItem($sAutoIt_Dir, $cTV) $cButton = GUICtrlCreateButton("Read", 10, 400, 80, 30) $cPossUncheck = GUICtrlCreateDummy() GUISetState() _Fill_TV($cRoot, $sAutoIt_Dir, "*.*") GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton ConsoleWrite("----------------------------" & @CRLF) For $i = 1 To $aFolderItem[0] If _GUICtrlTreeView_GetChecked($cTV, $aFolderItem[$i]) Then ConsoleWrite(_GUICtrlTreeView_GetText($cTV, $aFolderItem[$i]) & " is checked" & @CRLF) EndIf Next For $i = 1 To $aFileItem[0] If _GUICtrlTreeView_GetChecked($cTV, $aFileItem[$i]) Then ConsoleWrite(_GUICtrlTreeView_GetText($cTV, $aFileItem[$i]) & " is checked" & @CRLF) EndIf Next Case $cPossUncheck _PossUncheck_Parents(GUICtrlRead($cPossUncheck)) EndSwitch WEnd Func _Fill_TV($cTV, $sRoot, $sFile_Mask) Local $aLevel[100] = [$cTV], $iLevel, $aFolders, $sFullFolderpath, $sFolderName ; Add root files _Add_Files($sAutoIt_Dir, "*.*", $aLevel[0]) ; List folders $aFolders = _RecFileListToArray($sAutoIt_Dir, "*", 2, 1, 1, 1) ; Add folders For $i = 1 To $aFolders[0] $sFullFolderpath = $aFolders[$i] ; Count StringRegExpReplace($sFullFolderpath, "", "") $iLevel = @extended ; Extract folder name from path $sFolderName = StringRegExpReplace($sFullFolderpath, "(.*|^)(.*)", "$2") ; Add to TV and store item ControlID $aLevel[$iLevel] = GUICtrlCreateTreeViewItem($sFolderName, $aLevel[$iLevel - 1]) $aFolderItem[0] += 1 If UBound($aFolderItem) = $aFolderItem[0] Then ReDim $aFolderItem[$aFolderItem[0] * 2] $aFolderItem[$aFolderItem[0]] = $aLevel[$iLevel] ; Add files within folder _Add_Files($sRoot & $aFolders[$i], $sFile_Mask, $aLevel[$iLevel]) Next ; ReDim arrays to correct size ReDim $aFolderItem[$aFolderItem[0] + 1] ReDim $aFileItem[$aFileItem[0] + 1] EndFunc Func _Add_Files($sFolderPath, $sFile_Mask, $hTreeView_Parent) ; List files Local $aFileArray = _RecFileListToArray($sFolderPath, $sFile_Mask, 1, 0, 1, 0) ; Add files to TreeView If IsArray($aFileArray) Then For $j = 1 To $aFileArray[0] $aFileItem[0] += 1 If UBound($aFileItem) = $aFileItem[0] Then ReDim $aFileItem[$aFileItem[0] * 2] $aFileItem[$aFileItem[0]] = GUICtrlCreateTreeViewItem($aFileArray[$j], $hTreeView_Parent) Next EndIf EndFunc ;==>_Add_Files Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $cCID = BitAnd($wParam, 0x0000FFFF) ; ControlID Local $tStruct = DllStructCreate("dword;int;int", $lParam) Switch DllStructGetData($tStruct, 3) ; Code Case $NM_CLICK, $TVN_KEYDOWN Local $tMousePos = _WinAPI_GetMousePos(True, DllStructGetData($tStruct, 1)) ; HWndFrom Switch _GUICtrlTreeView_HitTest($cCID, DllStructGetData($tMousePos, 1), DllStructGetData($tMousePos, 2)) Case 64 $cTVItem = _GUICtrlTreeView_HitTestItem($cCID, DllStructGetData($tMousePos, 1), DllStructGetData($tMousePos, 2)) $sText = _GUICtrlTreeView_GetText($cTV, $cTVItem) ; Is it a node If _GUICtrlTreeView_GetChildren($cTV, $cTVItem) Then ; Check/uncheck the children as required If _GUICtrlTreeView_GetChecked($cTV, $cTVItem) Then _CheckUncheck_Children($cTVItem, False) Else _CheckUncheck_Children($cTVItem, True) ; And go back up the tree to see if parents need to be checked as well _Check_Parents($cTVItem) EndIf Else ; If child unchecked, check if parents need unchecking If _GUICtrlTreeView_GetChecked($cTV, $cTVItem) Then ; We need to do this as the TreeView must clear the check before we check GUICtrlSendToDummy($cPossUncheck, $cTVItem) Else ; Check parents up the line _Check_Parents($cTVItem) EndIf EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _PossUncheck_Parents($hHandle) ; Get the handle of the parent $hParent = _GUICtrlTreeView_GetParentHandle($cTV, $hHandle) ; If there is no parent If $hParent = 0 Then Return EndIf ; Set flag Local $fAll_Unchecked = True ; Run through all children to see if any checked ; Get the handle of the first child $hChild = _GUICtrlTreeView_GetFirstChild($cTV, $hParent) ; If there is no child If $hChild = 0 Then Return EndIf ; Is child checked If _GUICtrlTreeView_GetChecked($cTV, $hChild) Then ; Clear flag $fAll_Unchecked = False Else ; Now look for all children While 1 ; Look for next child $hChild = _GUICtrlTreeView_GetNextChild($cTV, $hChild) ; Exit the loop if none found If $hChild = 0 Then ExitLoop EndIf ; Is child checked If _GUICtrlTreeView_GetChecked($cTV, $hChild) Then ; Clear flag $fAll_Unchecked = False ExitLoop EndIf WEnd EndIf ; If all checked than uncheck - or check if not If $fAll_Unchecked Then _GUICtrlTreeView_SetChecked($cTV, $hParent, False) Else _GUICtrlTreeView_SetChecked($cTV, $hParent, True) EndIf ; Now look further up the tree _PossUncheck_Parents($hParent) EndFunc Func _Check_Parents($hHandle) ; Get the handle of the parent $hParent = _GUICtrlTreeView_GetParentHandle($cTV, $hHandle) ; If there is no parent If $hParent = 0 Then Return EndIf ; Check the parent _GUICtrlTreeView_SetChecked($cTV, $hParent) ; And look for the grandparent and so on _Check_Parents($hParent) EndFunc Func _CheckUncheck_Children($hHandle, $fState) ; Get the handle of the first child $hChild = _GUICtrlTreeView_GetFirstChild($cTV, $hHandle) ; If there is no child If $hChild = 0 Then Return EndIf ; Check/Uncheck the child _GUICtrlTreeView_SetChecked($cTV, $hChild, $fState) _CheckUncheck_Children($hChild, $fState) ; Now look for all grandchildren While 1 ; Look for next child $hChild = _GUICtrlTreeView_GetNextChild($cTV, $hChild) ; Exit the loop if none found If $hChild = 0 Then ExitLoop EndIf ; Uncheck the child _GUICtrlTreeView_SetChecked($cTV, $hChild, $fState) ; Check for children _CheckUncheck_Children($hChild, $fState) ; And then look for the next child WEnd EndFunc
Let me know if it is not quite right. :)

M23

Thanks Melba. Is that possible to show the entire C: drive in tree view with above code ? instead of showing only the folder Autoit. i tried changing the code but not able to get the result :) as usual your code is bit difficult for me to analyse :D

Edited by Syed23, 23 August 2012 - 01:12 PM.

Thank you,Regards,K.Syed Ibrahim.

#13 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,318 posts

Posted 23 August 2012 - 03:43 PM

Syed23,

Replace these 2 lines:
$sAutoIt_Dir = StringReplace(@AutoItExe, "autoit3.exe","") $cRoot = GUICtrlCreateTreeViewItem($sAutoIt_Dir, $cTV)

with these
$sInit_Dir = "C:" $cRoot = GUICtrlCreateTreeViewItem($sInit_Dir, $cTV)

But I warn you in advance, it will be VERY, VERY slow - in fact you might die of old age before it displays. And even then it might not display at all as I have no idea how many items you can put in a TreeView - and most C drives have a lot of files to list. ;)

So do not blame me when something horrible happens to you or yrou machine! :D

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#14 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 31 August 2012 - 11:04 AM

Syed23,

Replace these 2 lines:

$sAutoIt_Dir = StringReplace(@AutoItExe, "autoit3.exe","") $cRoot = GUICtrlCreateTreeViewItem($sAutoIt_Dir, $cTV)
with these
$sInit_Dir = "C:" $cRoot = GUICtrlCreateTreeViewItem($sInit_Dir, $cTV)
But I warn you in advance, it will be VERY, VERY slow - in fact you might die of old age before it displays. And even then it might not display at all as I have no idea how many items you can put in a TreeView - and most C drives have a lot of files to list. ;)

So do not blame me when something horrible happens to you or yrou machine! :D

M23

I can not blame you :) because you are helping me right? i have just changed my code desing to wrok accordingly to my project. in my tool i have 2 drop down boxes where select the options to explore drive. For example if i select drive "C:" in my first drop down and folder name in second drop down box then if pass the variable wiht guictrlread() in to the function _RecFilelisttoArray() it is not displaying anything. is there any reason?

Here is code of that part

$hTreeView = _GUICtrlTreeView_Create($BaseGUI, 370, 70, 340, 300, $iStyle, $WS_EX_CLIENTEDGE) _GUICtrlTreeView_BeginUpdate($hTreeView) $aArray = _RecFileListToArray(GUICtrlRead($DrivePath) & "" & GUICtrlRead($ProfileBox)) $hItem = _GUICtrlTreeView_Add($hTreeView, 0, GUICtrlRead($DrivePath) & "" & GUICtrlRead($ProfileBox) & "") _GUICtrlTreeView_SetState($hTreeView, $hItem, $TVIS_EXPANDED) _ArrayDisplay($aArray) For $x = 1 To UBound($aArray) - 1 ; For $y = 1 To Random(2, 10, 1) $So = _GUICtrlTreeView_AddChild($hTreeView, $hItem, $aArray[$x]) $Laray = _RecFileListToArray(GUICtrlRead($DrivePath) & "" & GUICtrlRead($ProfileBox) & "" & $aArray[$x]) For $Y = 1 To UBound($Laray) - 1 _GUICtrlTreeView_AddChild($hTreeView, $So, $Laray[$Y]) Next ; Next Next _GUICtrlTreeView_EndUpdate($hTreeView)

if the same _RecFilelistToArray() function with hardcoded it is working fine. please see the working example below of _recFilelisttArray() below

#include "RecFileListToArray.au3" #include"Array.au3" $list1 = "C:" $list2 = "users" $list = $list1 &""& $list2 $aArray = _RecFileListToArray($list) _ArrayDisplay($aArray)

any suggestion for me?

Edited by Syed23, 31 August 2012 - 11:07 AM.

Thank you,Regards,K.Syed Ibrahim.

#15 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,318 posts

Posted 31 August 2012 - 07:08 PM

Syed23,

any suggestion for me?

Yes, do some debugging to find out what path you are actually passing to the UDF. :)

If it works when you hardcode the path and does not when you create the path programatically, then you must suspect the path you create. A simple ConsoleWrite or MsgBox will give you the answer. ;)

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#16 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 01 September 2012 - 03:12 PM

Syed23,


Yes, do some debugging to find out what path you are actually passing to the UDF. :)

If it works when you hardcode the path and does not when you create the path programatically, then you must suspect the path you create. A simple ConsoleWrite or MsgBox will give you the answer. ;)

M23

Thanks, but to be honest i have tried already those. if i use msgbox inide the function as below it works. I mean it shows the path..
Msgbox(0,"",GUICtrlRead($DrivePath)&""&GUICtrlRead($ProfileBox))

if i do the same thing in consolewrite inside the function that does not works :'( i mean that does not write anything even "i am in" message

consolewrite(GUICtrlRead($DrivePath)&""&GUICtrlRead($ProfileBox))


this may make you to be frustrated for giving bit and piece information so i give my entire code here..

AutoIt         
#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=database-next.ico #AutoIt3Wrapper_Res_Comment=Data Restoration Utility #AutoIt3Wrapper_Res_Description=Data Restoration Utility #AutoIt3Wrapper_Res_Fileversion=1.0.0.1 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p #AutoIt3Wrapper_Res_LegalCopyright=Site Support Team #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker ://////=__= #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <TreeViewConstants.au3> #include "_XMLDomWrapper.au3" #include "GIFAnimation.au3" ; #include "GDIpProgress.au3" #include <GuiRichEdit.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include "Bit.au3" #include <ComboConstants.au3> #include"Array.au3" #include"Pst.au3" #include<File.au3> #include <ProgressConstants.au3> #include"ReduceMemory.au3" #include <_LargeFileCopy.au3> #include "RecFileListToArray.au3" #include "ExtMsgBox.au3" #include "Marquee.au3" Opt('TrayAutoPause', 0) Global $DocER = 0 Global $Docsel = 0 Global $tri = 0 Global $Err_msg = _WinAPI_GetLastErrorMessage() FileInstall("C:UsersQ03200Desktoptick.jpg", @ScriptDir & "tick.jpg", 1) FileInstall("C:UsersQ03200Desktoperror.jpg", @ScriptDir & "error.jpg", 1) FileInstall("C:UsersQ03200Desktopinfo.jpg", @ScriptDir & "info.jpg", 1) HotKeySet("{F1}", "about") FileInstall("C:UsersQ03200DesktopLocation.xml", @ScriptDir & "Location.xml", 1) Global $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) Global $hItem, $hTreeView Global $Copy = False Global $TickFile = @ScriptDir & "tick.jpg" Global $ErrorFile = @ScriptDir & "error.jpg" Global $info = @ScriptDir & "info.jpg" Global $GetpathArray[20] Global $About, $Aboutitem, $check, $ret Global $BaseGUI, $Sourcedrive, $ErrorLabel, $DrivePath, $DestDrive, $DestPath, $aArray, $OS, $OSver, $i, $s, $processviewer, $DESK, $FAV, $OFF, $AVA, $CRYPTO, $PSTS, $Others Global $StartButton, $CancelButton, $msg, $users, $prog, $m, $numberOfChannels, $file, $pst, $hGIF, $Comment, $State, $data, $Destfav, $Sourcefav, $Desktop, $Favorites Global $DocsAr, $mds, $Sourcedocs, $Destdocs, $SourceTrans, $Trans, $DestTrans, $Mydocs, $Transfer, $iMemo, $Label, $Appdata, $AVAya, $Docs, $md, $SourceDesk, $DestDesk, $mf, $mo Global $ma, $mc, $mt, $t, $te, $split, $subtime = 0 Global $Title = "Data Copying Utility" Global $aTSR = _GetTotalScreenResolution() Global $Log = @ProgramFilesDir & "Enterprise DesktopLogsDRU.log" Global $iProgress_1, $z = 0 Global $filedest = "C:TempwaitAnimated.gif" Global $Net = 0 Global $DRI = 0, $DER = 0 Global $Desktop, $TransDest, $Transource, $TransPercent, $join FileInstall("C:UsersQ03200DesktopwaitAnimated.gif", $filedest, 1) $BaseGUI = GUICreate($Title, 750, 570, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_GROUP, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) GUISetBkColor(0xFAFAFA) $Sourcedrive = GUICtrlCreateLabel("Select the Source Drive", 10, 10, 120, 40) $ErrorLabel = GUICtrlCreateLabel("", 10, 440, 480, 40) GUICtrlSetState(-1, $GUI_HIDE) $DrivePath = GUICtrlCreateCombo("C:", 135, 5, 60, 50, $CBS_DROPDOWNLIST) $DestDrive = GUICtrlCreateLabel("Data Destination Location", 230, 10, 200, 40) $DestPath = GUICtrlCreateCombo("C:", 370, 5, 60, 50, $CBS_DROPDOWNLIST) $aArray = DriveGetDrive("ALL") $OS = GUICtrlCreateLabel("Select Source OS", 475, 10, 100, 40) $OSver = GUICtrlCreateCombo("Win 7-64 Bit", 570, 5, 110, 50, $CBS_DROPDOWNLIST) GUICtrlSetData($OSver,"Win 7-32 Bit") GUICtrlSetData($OSver, StringUpper("XP")) If @error Then ; An error occurred when retrieving the drives. MsgBox(16, $Title & "DriveGetDrive", "Error occured while trying to fetch the drive details.") Exit Else For $i = 1 To $aArray[0] ; Show all the drives found and convert the drive letter to uppercase. If $aArray[$i] <> "C:" Then GUICtrlSetData($DrivePath, StringUpper($aArray[$i])) EndIf Next EndIf $processviewer = GUICtrlCreateGroup("Restore Options", 10, 40, 280, 340) $Mydocs = GUICtrlCreateCheckbox("My Documents", 160, 70, 100, 40) $Transfer = GUICtrlCreateCheckbox("All", 30, 70, 100, 40) $Unckec = GUICtrlCreateCheckbox("UnCheck All", 30, 60, 100, 40) GUICtrlSetState(-1,$GUI_HIDE) $DESK = GUICtrlCreateCheckbox("Desktop", 30, 120, 100, 40) $FAV = GUICtrlCreateCheckbox("Favorites", 30, 170, 100, 40) $OFF = GUICtrlCreateCheckbox("Office Settings", 30, 220, 100, 40) $AVA = GUICtrlCreateCheckbox("Avaya", 160, 120, 100, 40) $CRYPTO = GUICtrlCreateCheckbox("Crypto Soft Token", 160, 170, 120, 40) $PSTS = GUICtrlCreateCheckbox("PST Files", 160, 220, 100, 40) $StartButton = GUICtrlCreateButton("Restore", 15, 490, 60, 40) $CancelButton = GUICtrlCreateButton("Exit", 200, 490, 60, 40) $Profiles = GUICtrlCreateLabel("Select Folder", 30, 285, 100, 40) $ProfileBox = GUICtrlCreateCombo("", 160, 280, 100, 40, $CBS_DROPDOWNLIST) GUICtrlSetstate($ProfileBox,$GUI_DISABLE) $processviewer = GUICtrlCreateGroup("", 360, 40, 370, 340) GUICtrlSetData($processviewer, "Result Viewer") ;option() ;GUIDelete($hGui) $iProgress_1 = GUICtrlCreateProgress(370, 500, 240, 20, $PBS_MARQUEE) GUICtrlSetState($iProgress_1, $GUI_HIDE) $Label = GUICtrlCreateLabel("", 370, 430, 200, 40) $hMarquee = _GUICtrlMarquee_Create("Contact "&'"'&"syed.ibrahim@kcc.com"&'" for any suggestion/issues...', 10, 510,300, 20) GUICtrlSetState(-1,$GUI_HIDE) ;_ProgressSetText($iProgress_1, "Checking...") ;_ProgressMarquee($iProgress_1, 2, 0) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _FileWriteLog($Log, "DRU>INFO>Launch>Tool Launched!") While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Or $msg = $CancelButton Then FileDelete(@ScriptDir & "Location.xml") FileDelete(@ScriptDir & "tick.jpg") FileDelete(@ScriptDir & "error.jpg") FileDelete(@ScriptDir & "info.jpg") _GUICtrlTreeView_Destroy($hTreeView) _GUICtrlRichEdit_Destroy($iMemo) _FileWriteLog($Log, "DRU>INFO>Exit>User Selected Exit option. Tool closed successfully!") Exit EndIf If $msg = $GUI_EVENT_PRIMARYDOWN Then Local $tMPos = _WinAPI_GetMousePos(True, $hTreeView) Local $tHitTest = _GUICtrlTreeView_HitTestEx($hTreeView, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2)) Local $iFlags = DllStructGetData($tHitTest, "Flags") Select Case BitAND($iFlags, $TVHT_ONITEMSTATEICON) Local $hItem = _GUICtrlTreeView_HitTestItem($hTreeView, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2)) Local $fChecked = False If _GUICtrlTreeView_GetChecked($hTreeView, $hItem) Then $fChecked = True _TvCheckbox($hItem, $fChecked) ; EndSelect EndSelect EndIf If $msg = $DrivePath Then If GUICtrlRead($DrivePath) <> "" Then GUICtrlSetstate($ProfileBox,$GUI_ENABLE) GUICtrlSetData($ProfileBox,"") Local $FileList = _FileListToArray(GUICtrlRead($DrivePath)&"", "*.*", 2) For $i = 1 To UBound($FileList) - 1 GUICtrlSetData($ProfileBox, $FileList[$i]&@CRLF) Next Else GUICtrlSetData($ErrorLabel, "Source directory can not be Blank. Please select the correct drive.") GUICtrlSetColor($ErrorLabel, 0xff0000) GUICtrlSetState($ErrorLabel, $GUI_SHOW) _FileWriteLog($Log, "DRU>Warning>Source Drive Status>User Selected Blank drive - !" & GUICtrlRead($DrivePath)) EndIf EndIf If $msg = $ProfileBox Then profilebox() EndIf If $msg = $Transfer Then GUICtrlSetState($Transfer,$GUI_UNCHECKED) GUICtrlSetState($Transfer,$GUI_HIDE) GUICtrlSetState($Unckec,$GUI_SHOW) GUICtrlSetState($Mydocs,$GUI_CHECKED) GUICtrlSetState($DESK,$GUI_CHECKED) GUICtrlSetState($FAV,$GUI_CHECKED) GUICtrlSetState($AVA,$GUI_CHECKED) GUICtrlSetState($CRYPTO,$GUI_CHECKED) GUICtrlSetState($PSTS,$GUI_CHECKED) GUICtrlSetState($OFF,$GUI_CHECKED) EndIf If $msg = $Unckec Then GUICtrlSetState($Unckec,$GUI_UNCHECKED) GUICtrlSetState($Unckec,$GUI_HIDE) GUICtrlSetState($Transfer,$GUI_SHOW) GUICtrlSetState($Mydocs,$GUI_UNCHECKED) GUICtrlSetState($DESK,$GUI_UNCHECKED) GUICtrlSetState($FAV,$GUI_UNCHECKED) GUICtrlSetState($AVA,$GUI_UNCHECKED) GUICtrlSetState($CRYPTO,$GUI_UNCHECKED) GUICtrlSetState($PSTS,$GUI_UNCHECKED) GUICtrlSetState($OFF,$GUI_UNCHECKED) EndIf If $msg = $StartButton Then process() ;GUICtrlSetState($iProgress_1, $GUI_SHOW) If $check = 1 Then _GUICtrlRichEdit_WriteLine($iMemo, "Task has been completed! " & @CRLF, "", "", 0x008000) GUICtrlSetState($iProgress_1, $GUI_HIDE) out() GUISetState(@SW_SHOWNORMAL, $BaseGUI) GUICtrlSetState($StartButton, $GUI_HIDE) GUICtrlSetState($hMarquee,$GUI_SHOW) GUICtrlSetPos($CancelButton, 590, 490, 150, 60) ElseIf $check = -1 Then GUICtrlSetState($iProgress_1, $GUI_HIDE) GUICtrlSetState($hMarquee,$GUI_HIDE) EndIf EndIf WEnd Func out() GUICtrlSetState($DrivePath, $GUI_DISABLE) GUICtrlSetState($DestPath, $GUI_DISABLE) GUICtrlSetState($Unckec, $GUI_DISABLE) GUICtrlSetState($ProfileBox, $GUI_DISABLE) GUICtrlSetState($OSver, $GUI_DISABLE) If GUICtrlRead($Mydocs) <> 1 Then GUICtrlSetState($Mydocs, $GUI_DISABLE) EndIf If GUICtrlRead($Transfer) <> 1 Then GUICtrlSetState($Transfer, $GUI_DISABLE) EndIf If GUICtrlRead($DESK) <> 1 Then GUICtrlSetState($DESK, $GUI_DISABLE) EndIf If GUICtrlRead($FAV) <> 1 Then GUICtrlSetState($FAV, $GUI_DISABLE) EndIf If GUICtrlRead($OFF) <> 1 Then GUICtrlSetState($OFF, $GUI_DISABLE) EndIf If GUICtrlRead($AVA) <> 1 Then GUICtrlSetState($AVA, $GUI_DISABLE) EndIf If GUICtrlRead($CRYPTO) <> 1 Then GUICtrlSetState($CRYPTO, $GUI_DISABLE) EndIf If GUICtrlRead($PSTS) <> 1 Then GUICtrlSetState($PSTS, $GUI_DISABLE) EndIf EndFunc ;==>out Func profilebox() _GUICtrlTreeView_Destroy($hTreeView) If GUICtrlRead($DrivePath) <> "" Then GUICtrlSetData($ErrorLabel, "") GUICtrlSetState($ErrorLabel, $GUI_HIDE) GUICtrlSetData($processviewer, "Tree Viewer") _GUICtrlRichEdit_Destroy($iMemo) $hTreeView = _GUICtrlTreeView_Create($BaseGUI, 370, 70, 340, 300, $iStyle, $WS_EX_CLIENTEDGE) _GUICtrlTreeView_BeginUpdate($hTreeView) $aArray = _RecFileListToArray(GUICtrlRead($DrivePath)&""&GUICtrlRead($ProfileBox)) $hItem = _GUICtrlTreeView_Add($hTreeView, 0, GUICtrlRead($DrivePath)&""&GUICtrlRead($ProfileBox) & "") _GUICtrlTreeView_SetState($hTreeView, $hItem, $TVIS_EXPANDED) _ArrayDisplay($aArray) For $x = 1 To UBound($aArray) - 1 ; For $y = 1 To Random(2, 10, 1) $So = _GUICtrlTreeView_AddChild($hTreeView, $hItem, $aArray[$x]) $Laray = _RecFileListToArray(GUICtrlRead($DrivePath)&""&GUICtrlRead($ProfileBox)&"" & $aArray[$x]) For $Y = 1 To UBound($Laray) - 1 _GUICtrlTreeView_AddChild($hTreeView, $So, $Laray[$Y]) Next ; Next Next _GUICtrlTreeView_EndUpdate($hTreeView) Else GUICtrlSetData($ErrorLabel, "Source directory can not be Blank. Please select the correct drive.") GUICtrlSetColor($ErrorLabel, 0xff0000) GUICtrlSetState($ErrorLabel, $GUI_SHOW) GUICtrlSetState($Transfer, $GUI_UNCHECKED) _FileWriteLog($Log, "DRU>Warning>Source Drive Status>User Selected Blank drive - !" & GUICtrlRead($DrivePath)) EndIf EndFunc Func process() $a = _GUICtrlTreeView_GetTree($hTreeView) _FileWriteLog($Log, "DRU>INFO>Process>User Selected Process option") _check() If $ret >= 1 Then If GUICtrlRead($OSver) = "XP" Then ;Foldexist function defined on PST.au3 If Foldexist(GUICtrlRead($DrivePath) & "Drivers") = True Then $users = "Documents and Settings" $prog = "Program Files" $Appdata = "Documents and Settings" & @UserName & "Application DataMicrosoft" $AVAya = "Documents and Settings" & @UserName & "Application DataAvaya" $Docs = "Documents and Settings" & @UserName & "My Documents" $check = 1 Else MsgBox(48, "OS MisMatch!", "Operating System has been selected wrongly. Please select the appropriate one!") EndIf ElseIf GUICtrlRead($OSver) = "Win 7-64 Bit" Then If Foldexist(GUICtrlRead($DrivePath) & "Program Files (x86)") = True Then $users = "Users" $prog = "Program Files (x86)" $Appdata = "Users" & @UserName & "AppDataRoamingMicrosoft" $AVAya = "Users" & @UserName & "AppDataRoamingAvaya" $Docs = "Users" & @UserName & "Documents" $check = 1 Else MsgBox(48, "OS MisMatch!", "Operating System has been selected wrongly. Please select the appropriate one!") EndIf ElseIf GUICtrlRead($OSver) = "Win 7-32 Bit" Then If Foldexist(GUICtrlRead($DrivePath) & "Program Files (x86)") = False And Foldexist(GUICtrlRead($DrivePath) & "users") = True Then $users = "Users" $prog = "Program Files" $Appdata = "Users" & @UserName & "AppDataRoamingMicrosoft" $AVAya = "Users" & @UserName & "AppDataRoamingAvaya" $Docs = "Users" & @UserName & "Documents" $check = 1 Else MsgBox(48, "OS MisMatch!", "Operating System has been selected wrongly. Please select the appropriate one!") EndIf EndIf EndIf If $check = 1 Then If ProcessExists("outlook.exe") Then Do _ExtMsgBoxSet(2, 0, -1, -1, 9, "Arial") _ExtMsgBox($MB_ICONEXCLAM, "Continue", "Open Application", "Outlook is Open. Please close the outlook and click on Continue.") _ExtMsgBoxSet(Default) ; MsgBox(48, "Open Application", "Outlook is running on this machine. In order restore data now the tool will close the outlook.") ; ;ProcessClose("outlook.exe") ; ;_FileWriteLog($Log, "DRU>Outlook process>PST>Outlook was running on this machine and killed the outlook") Until ProcessExists("outlook.exe") = 0 EndIf GUICtrlSetData($ErrorLabel, "") _GUICtrlTreeView_Destroy($hTreeView) GUICtrlSetData($processviewer, "Result Viewer") $iMemo = _GUICtrlRichEdit_Create($BaseGUI, "******************************************************************************" & @CRLF, 370, 70, 340, 300, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_MULTILINE + $ES_READONLY) _GUICtrlRichEdit_WriteLine($iMemo, "Restoring Data" & @CRLF, "", "", 0x000000) _GUICtrlRichEdit_WriteLine($iMemo, "******************************************************************************" & @CRLF, "", "", 0x000000) GUICtrlSetState($iProgress_1, $GUI_SHOW) GUICtrlSendMsg($iProgress_1, $PBM_SETMARQUEE, True, 50) If GUICtrlRead($Mydocs) = "1" Then _GUICtrlRichEdit_WriteLine($iMemo, "Started copying MY Documents folder " & @CRLF, "", "", 0xFE2EF7) $DocsAr = _RecFileListToArray(GUICtrlRead($DrivePath) & $Docs & "", "*", 0, 1, 1) If IsArray($DocsAr) Then _GUICtrlRichEdit_WriteLine($iMemo, UBound($DocsAr) & " Files to be copied. Please wait... " & @CRLF, "", "", 0xFE2EF7) For $i = 0 To UBound($DocsAr) - 1 _FileWriteLog($Log, "DRU>INFO>DOCS>Source location>" & GUICtrlRead($DrivePath) & $Docs & "" & $DocsAr[$i]) _FileWriteLog($Log, "DRU>INFO>DOCS>Destination location>" & "C:Users" & @UserName & "Documents" & "" & $DocsAr[$i]) ; If StringInStr($DocsAr[$i], ".") <> 0 Then $mds = _LargeFileCopy(GUICtrlRead($DrivePath) & $Docs & "" & $DocsAr[$i], "C:Users" & @UserName & "Documents" & "" & $DocsAr[$i], BitOR(1, 2, 8)) If $mds = 1 Then _FileWriteLog($Log, "DRU>INFO>DESKTOP - File Copy> copied the file - " & $DocsAr[$i]) $DRI = $DRI + 1 ElseIf $mds <> 1 Then _FileWriteLog($Log, "DRU>ERROR>DESKTOP - File Copy>Failed to copy the file - >" & $DocsAr[$i] & " Error value = " & @error) If @error = 1 Then _FileWriteLog($Log, "DRU>WARNING>DESKTOP - File Copy>Failed to copy the file - >Failed to open source file, or source was a directory") ElseIf @error = 2 Then _FileWriteLog($Log, "DRU>WARNING>DESKTOP - File Copy>Failed to copy the file - >Destination file exists and overwrite flag not set") ElseIf @error = 3 Then _FileWriteLog($Log, "DRU>WARNING>DESKTOP - File Copy>Failed to copy the file - >Failed to create destination file") $DER = $DER + 1 ElseIf @error = 4 Then _FileWriteLog($Log, "DRU>WARNING>DESKTOP - File Copy>Failed to copy the file - >Read error during copy") $DER = $DER + 1 ElseIf @error = 5 Then _FileWriteLog($Log, "DRU>WARNING>DESKTOP - File Copy>Failed to copy the file - >Write error during copy") $DER = $DER + 1 ElseIf @error = 6 Then _FileWriteLog($Log, "DRU>WARNING>DESKTOP - File Copy>Failed to copy the file - >Verify failed") $DER = $DER + 1 EndIf EndIf ; Else ; _FileWriteLog($Log, "DRU>INFO>MY Docs>" & "Not in to the copy loop" & $DocsAr[$i]) ; EndIf Next GUICtrlSetState($Mydocs, $GUI_HIDE) $Sourcedocs = DirGetSize(GUICtrlRead($DrivePath) & $Docs) $Destdocs = DirGetSize("C:Users" & @UserName & "Documents") If Round($Destdocs / 1024 / 1024) = Round($Sourcedocs / 1024 / 1024) Then _GUICtrlRichEdit_WriteLine($iMemo, "Documents Folder copied successfully " & @CRLF, "", "", 0x008000) _FileWriteLog($Log, "DRU>INFO>DOCS>Documents folder copied successfully!") GUICtrlCreatePic($TickFile, 160, 70, 16, 16) GUICtrlCreateLabel("My Documents", 180, 70, 100, 30) ;MsgBox(0,"SIZE","Destination Size = " & Round($Destdocs / 1024 / 1024) &@CRLF&@CRLF&@CRLF&@CRLF& "Source Size = "& Round($Sourcedocs / 1024 / 1024)) ; ElseIf $DER >= 1 Then ; _GUICtrlRichEdit_WriteLine($iMemo, "Some Files are not copied properly. Please copy it manually " & @CRLF, "", "", 0xCDA30C) ; _FileWriteLog($Log, "DRU>INFO>DOCS>Some files are not copied properly!") ElseIf Round($Destdocs / 1024 / 1024) <> Round($Sourcedocs / 1024 / 1024) Then GUICtrlCreatePic($ErrorFile, 160, 70, 16, 16) GUICtrlCreateLabel("My Documents", 180, 70, 100, 30) _GUICtrlRichEdit_WriteLine($iMemo, "Some Files are not copied properly. Please copy it manually! Also please send the log file to the tool Admin" & @CRLF, "", "", 0xFF0000) _FileWriteLog($Log, "DRU>Error>DOCS>unable to copy MY Documents folder. Source Size = " & Round($Sourcedocs / 1024 / 1024) & ". Destination size = " & Round($Destdocs / 1024 / 1024) & ". Value of DER = " & $DER) ;MsgBox(0, "SIZE", "Destination Size = " & Round($Destdocs / 1024 / 1024) & @CRLF & @CRLF & @CRLF & @CRLF & "Source Size = " & Round($Sourcedocs / 1024 / 1024)) EndIf Else GUICtrlSetState($Mydocs, $GUI_HIDE) GUICtrlCreatePic($TickFile, 160, 70, 16, 16) GUICtrlCreateLabel("My Documents", 180, 70, 100, 30) _GUICtrlRichEdit_WriteLine($iMemo, UBound($DocsAr) & " Files to be copied!" & @CRLF, "", "", 0x2E2EFE) _FileWriteLog($Log, "DRU>Error>DOCS>Variable Documents does not return array value") EndIf $DER = 0 $DRI = 0 EndIf If GUICtrlRead($DESK) = "1" Then _GUICtrlRichEdit_WriteLine($iMemo, "Started copying Desktop folder " & @CRLF, "", "", 0xFE2EF7) ; $Dessel = 1 $Desktop = _RecFileListToArray(GUICtrlRead($DrivePath) & $users & @UserName & "Desktop" & "", "*", 0, 1, 1) If IsArray($Desktop) Then _GUICtrlRichEdit_WriteLine($iMemo, UBound($Desktop) & " Files to be copied. Please wait... " & @CRLF, "", "", 0xFE2EF7) ;$md = DirCopy(GUICtrlRead($DrivePath) & $users & @UserName & $Comment[1], "C:users" & @UserName & $Comment[1], 1) For $i = 0 To UBound($Desktop) - 1 _FileWriteLog($Log, "DRU>INFO>DESKTOP>Source location>" & GUICtrlRead($DrivePath) & $users & @UserName & "Desktop" & $Desktop[$i]) _FileWriteLog($Log, "DRU>INFO>DESKTOP>Destination location>" & @DesktopDir & "" & $Desktop[$i]) ; If StringInStr($Desktop[$i], ".") <> 0 Then $md = _LargeFileCopy(GUICtrlRead($DrivePath) & $users & @UserName & "Desktop" & $Desktop[$i], @DesktopDir & "" & $Desktop[$i], BitOR(1, 2, 8)) If $md = 1 Then _FileWriteLog($Log, "DRU>INFO>DESKTOP - File Copy> copied the file - " & $Desktop[$i]) $DRI = $DRI + 1 ElseIf $md <> 1 Then _FileWriteLog($Log, "DRU>ERROR>DESKTOP - File Copy>Failed to copy the file - >" & $Desktop[$i] & " Error value = " & @error) $DER = $DER + 1 EndIf ; Else ; _FileWriteLog($Log, "DRU>INFO>Desktop>" & "Not in to the copy loop" & $Desktop[$i]) ; EndIf Next GUICtrlSetState($DESK, $GUI_HIDE) $SourceDesk = DirGetSize(GUICtrlRead($DrivePath) & $users & @UserName & "Desktop") $DestDesk = DirGetSize(@DesktopDir) If Round($DestDesk / 1024 / 1024) = Round($SourceDesk / 1024 / 1024) Then _GUICtrlRichEdit_WriteLine($iMemo, "Desktop Folder copied successfully " & @CRLF, "", "", 0x008000) _FileWriteLog($Log, "DRU>INFO>Desktop>Desktop folder copied successfully!") GUICtrlCreatePic($TickFile, 30, 120, 16, 16) GUICtrlCreateLabel("Desktop", 50, 120, 100, 40) ;ElseIf $DER >= 1 Then ; _GUICtrlRichEdit_WriteLine($iMemo, "Some Files are not copied properly. Please copy it manually " & @CRLF, "", "", 0xCDA30C) ; _FileWriteLog($Log, "DRU>INFO>Desktop>Some files are not copied properly!") ElseIf Round($DestDesk / 1024 / 1024) <> Round($SourceDesk / 1024 / 1024) Then GUICtrlCreatePic($ErrorFile, 30, 120, 16, 16) GUICtrlCreateLabel("Desktop", 50, 120, 100, 40) _GUICtrlRichEdit_WriteLine($iMemo, "Some Files are not copied properly. Please copy it manually! Also please send the log file to the tool Admin" & @CRLF, "", "", 0xFF0000) _FileWriteLog($Log, "DRU>Error>Desktop>unable to copy Desktop folder. Source Desk Size = " & Round($SourceDesk / 1024 / 1024) & ". Destination size = " & Round($DestDesk / 1024 / 1024) & ". Value of DER = " & $DER) EndIf Else GUICtrlSetState($DESK, $GUI_HIDE) GUICtrlCreatePic($TickFile, 30, 120, 16, 16) GUICtrlCreateLabel("Desktop", 50, 120, 100, 30) _GUICtrlRichEdit_WriteLine($iMemo, UBound($Desktop) & " Files to be copied!" & @CRLF, "", "", 0x2E2EFE) _FileWriteLog($Log, "DRU>Error>Desktop>Variable Desktop does not return array value") EndIf $DER = 0 $DRI = 0 EndIf If GUICtrlRead($FAV) = "1" Then $Favorites = _RecFileListToArray(GUICtrlRead($DrivePath) & $users & @UserName & "Favorites" & "", "*", 0, 1, 1) If IsArray($Favorites) Then _GUICtrlRichEdit_WriteLine($iMemo, UBound($Favorites) & " links to be copied. Please wait... " & @CRLF, "", "", 0xFE2EF7) For $i = 0 To UBound($Favorites) - 1 $t = 0 $te = 0 _FileWriteLog($Log, "DRU>INFO>FAV>Source location - " & GUICtrlRead($DrivePath) & $users & @UserName & "Favorites" & $Favorites[$i]) _FileWriteLog($Log, "DRU>INFO>FAV>Destination location - " & "C:users" & @UserName & "Favorites" & $Favorites[$i]) ;$mf = DirCopy(GUICtrlRead($DrivePath) & $users & @UserName & $Comment[1], "C:users" & @UserName & $Comment[1], 1) ; If StringInStr($Favorites[$i], ".") <> 0 Then $t = TimerInit() $mf = _LargeFileCopy(GUICtrlRead($DrivePath) & $users & @UserName & "Favorites" & $Favorites[$i], @FavoritesDir & "" & $Favorites[$i], BitOR(1, 2, 8)) $te = TimerDiff($t) If $mf = 1 Then _FileWriteLog($Log, "DRU>INFO>FAV - File Copy> copied the file - " & $Favorites[$i]) $subtime = $subtime + ($te / 1000) $DRI = $DRI + 1 ElseIf $mf <> 1 And StringInStr($Favorites[$i], ".") <> 0 Then _FileWriteLog($Log, "DRU>ERROR>FAV - File Copy>Failed to copy the file - >" & $Favorites[$i] & " Error value = " & $mf) $DER = $DER + 1 EndIf ; Else ; _FileWriteLog($Log, "DRU>WARNING>Favorites>" & "Not in to the copy loop" & $Favorites[$i]) ; EndIf Next GUICtrlSetState($FAV, $GUI_HIDE) $Sourcefav = DirGetSize(GUICtrlRead($DrivePath) & $users & @UserName & "Favorites") $Destfav = DirGetSize(@FavoritesDir) If Round($Destfav / 1024 / 1024) = Round($Sourcefav / 1024 / 1024) Then GUICtrlCreatePic($TickFile, 30, 170, 16, 16) GUICtrlCreateLabel("Favorites", 50, 170, 100, 30) _GUICtrlRichEdit_WriteLine($iMemo, "Favorites Folder copied successfully " & @CRLF, "", "", 0x008000) _FileWriteLog($Log, "DRU>INFO>FAV>FAV folder copied successfully!") ; ElseIf $DER >= 1 Then ; _GUICtrlRichEdit_WriteLine($iMemo, "Some Files are not copied properly. Please copy it manually " & @CRLF, "", "", 0xCDA30C) ; _FileWriteLog($Log, "DRU>INFO>FAV>Some files are not copied properly!") ElseIf Round($Destfav / 1024 / 1024) <> Round($Sourcefav / 1024 / 1024) And $DER = 0 Then GUICtrlCreatePic($ErrorFile, 30, 180, 16, 16) GUICtrlCreateLabel("Favorites", 50, 180, 100, 30) _GUICtrlRichEdit_WriteLine($iMemo, "Some Files are not copied properly. Please copy it manually! Also please send the log file to the tool Admin." & @CRLF, "", "", 0xFF0000) _FileWriteLog($Log, "DRU>Error>FAV>unable to copy FAV folder. Source Size = " & Round($Sourcefav / 1024 / 1024) & ". Destination size = " & Round($Destfav / 1024 / 1024) & ". Value of DER = " & $DER) EndIf Else GUICtrlSetState($FAV, $GUI_HIDE) GUICtrlCreatePic($TickFile, 30, 180, 16, 16) GUICtrlCreateLabel("Favorites", 50, 180, 100, 30) _GUICtrlRichEdit_WriteLine($iMemo, UBound($Favorites) & " Files to be copied!" & @CRLF, "", "", 0x2E2EFE) _FileWriteLog($Log, "DRU>Error>FAV>Variable FAV does not return array value") EndIf $DER = 0 $DRI = 0 _FileWriteLog($Log, "DRU>INFO>Time for Copying> copied the Favorites folder in " & $subtime & " Seconds") EndIf If GUICtrlRead($OFF) = "1" Then _GUICtrlRichEdit_WriteLine($iMemo, "Started copying Office folder " & @CRLF, "", "", 0xFE2EF7) $file = _XMLFileOpen(@ScriptDir & "Location.xml") $numberOfChannels = _XMLGetNodeCount("/root/off") For $s = 1 To $numberOfChannels Step +1 $Comment = _XMLGetChildText("/root/off[" & $s & "]") _ReduceMemory() $mo = DirCopy(GUICtrlRead($DrivePath) & $Appdata & $Comment[1], "C:users" & @UserName & "AppDataRoamingMicrosoft" & $Comment[1], 1) _FileWriteLog($Log, "DRU>INFO>OFF>Source location - " & GUICtrlRead($DrivePath) & $Appdata & $Comment[1]) _FileWriteLog($Log, "DRU>INFO>OFF>Destination location - " & "C:users" & @UserName & "AppDataRoamingMicrosoft" & $Comment[1]) GUICtrlSetState($OFF, $GUI_HIDE) If $mo = 1 Then _GUICtrlRichEdit_WriteLine($iMemo, "Office Folder copied successfully " & $Comment & @CRLF, "", "", 0x008000) _FileWriteLog($Log, "DRU>INFO>OFF>Office files Folder copied successfully - " & $Comment[1]) GUICtrlCreatePic($TickFile, 30, 220, 16, 16) GUICtrlCreateLabel("Office Settings", 50, 220, 100, 30) Else _GUICtrlRichEdit_WriteLine($iMemo, "Unable to copy Office folder. Error - " & @error & $Comment & @CRLF, "", "", 0xFF0000) _FileWriteLog($Log, "DRU>Error>OFF>unable to copy Office files folder - " & $Comment[1]) GUICtrlCreatePic($ErrorFile, 30, 220, 16, 16) GUICtrlCreateLabel("Office Settings", 50, 220, 100, 30) EndIf Next EndIf If GUICtrlRead($AVA) = "1" Then _GUICtrlRichEdit_WriteLine($iMemo, "Started copying Avaya folder " & @CRLF, "", "", 0xFE2EF7) _FileWriteLog($Log, "DRU>INFO>Avaya>Started copying the Avaya folder") $file = _XMLFileOpen(@ScriptDir & "Location.xml") $numberOfChannels = _XMLGetNodeCount("/root/avaya") For $s = 1 To $numberOfChannels Step +1 $Comment = _XMLGetChildText("/root/avaya[" & $s & "]") _ReduceMemory() $ma = DirCopy(GUICtrlRead($DrivePath) & $AVAya & $Comment[1], "C:users" & @UserName & "AppDataRoamingAvaya" & $Comment[1], 1) _FileWriteLog($Log, "DRU>INFO>Avaya>Source location - " & GUICtrlRead($DrivePath) & $AVAya & $Comment[1]) _FileWriteLog($Log, "DRU>INFO>Avaya>Destination location - " & "C:users" & @UserName & "AppDataRoamingAvaya" & $Comment[1]) Next GUICtrlSetState($AVA, $GUI_HIDE) If $ma = 1 Then GUICtrlCreatePic($TickFile, 160, 120, 16, 16) GUICtrlCreateLabel("Avaya", 180, 120, 100, 30) _GUICtrlRichEdit_WriteLine($iMemo, "Avaya Folder copied successfully " & $Comment & @CRLF, "", "", 0x008000) _FileWriteLog($Log, "DRU>INFO>Avaya>Avaya Folder copied successfully ") Else GUICtrlCreatePic($ErrorFile, 160, 120, 16, 16) GUICtrlCreateLabel("Avaya", 180, 120, 100, 30) _GUICtrlRichEdit_WriteLine($iMemo, "Unable to copy Avaya folder. Error - " & @error & $Comment & @CRLF, "", "", 0xFF0000) _FileWriteLog($Log, "DRU>Error>Avaya>unable to copy Avaya folder") EndIf EndIf If GUICtrlRead($CRYPTO) = "1" Then _GUICtrlRichEdit_WriteLine($iMemo, "Started copying Crypto folder " & @CRLF, "", "", 0xFE2EF7) _FileWriteLog($Log, "DRU>INFO>CRYPTO>Started copying the Crypto folder") $file = _XMLFileOpen(@ScriptDir & "Location.xml") $numberOfChannels = _XMLGetNodeCount("/root/cryp") For $s = 1 To $numberOfChannels Step +1 $Comment = _XMLGetChildText("/root/cryp[" & $s & "]") _ReduceMemory() _FileWriteLog($Log, "DRU>INFO>Crypto>Source location - " & GUICtrlRead($DrivePath) & $prog & $Comment[1]) _FileWriteLog($Log, "DRU>INFO>Crypto>Destination location - " & @ProgramFilesDir & "" & $Comment[1]) $mc = DirCopy(GUICtrlRead($DrivePath) & $prog & $Comment[1], @ProgramFilesDir & "" & $Comment[1], 1) GUICtrlSetState($CRYPTO, $GUI_HIDE) If $mc = 1 Then GUICtrlCreatePic($TickFile, 160, 170, 16, 16) GUICtrlCreateLabel("Crypto Soft Token", 180, 170, 100, 30) _GUICtrlRichEdit_WriteLine($iMemo, "Crypto Folder copied successfully " & @CRLF, "", "", 0x008000) _FileWriteLog($Log, "DRU>INFO>Crypto>Crypto folder copied successfully") Else GUICtrlCreatePic($ErrorFile, 160, 170, 16, 16) GUICtrlCreateLabel("Crypto Soft Token", 180, 170, 100, 30) _GUICtrlRichEdit_WriteLine($iMemo, "Unable to copy Crypto folder. Error - " & @error & $Comment & @CRLF, "", "", 0xFF0000) _FileWriteLog($Log, "DRU>Error>Crypto>unable to copy Crypto folder") EndIf Next EndIf If GUICtrlRead($PSTS) = "1" Then _GUICtrlRichEdit_WriteLine($iMemo, "Searching for PST file. Please wait.... " & @CRLF, "", "", 0x0000FF) $pst = _RecFileListToArray(GUICtrlRead($DrivePath), "*.pst", 1, 1) _FileWriteLog($Log, "DRU>INFO>PST>Started copying PST Files") _GUICtrlRichEdit_WriteLine($iMemo, UBound($pst) & " PST files need to be copied! " & @CRLF, "", "", 0xFE2EF7) If IsArray($pst) Then For $i = 0 To UBound($pst) - 1 $t = 0 $te = 0 If StringInStr($pst[$i], ".") <> 0 Then _FileWriteLog($Log, "DRU>INFO>PST>Source location - " & GUICtrlRead($DrivePath) & "" & $pst[$i]) $t = TimerInit() ; If StringInStr($pst[$i], "Local SettingsApplication DataMicrosoftOutlook") <> 0 Or StringInStr($pst[$i], "AppDataLocalMicrosoftOutlook") <> 0 Then ; $split = StringSplit($pst[$i], "") ; $m = _LargeFileCopy(GUICtrlRead($DrivePath) & "" & $pst[$i], "C:users" & @UserName & "AppDataLocalMicrosoftOutlook" & $split[UBound($split) - 1], BitOR(1, 2, 8)) ; $te = TimerDiff($t) ; Else ; $t = TimerInit() $m = _LargeFileCopy(GUICtrlRead($DrivePath) & "" & $pst[$i], "C:" & $pst[$i], BitOR(1, 2, 8)) $te = TimerDiff($t) ; EndIf If $m = 1 Then _FileWriteLog($Log, "DRU>INFO>PST - File Copy> copied the file - " & $pst[$i]) _FileWriteLog($Log, "DRU>INFO>Time for Copying> copied the file - " & $pst[$i] & " in " & $te / 1000 & " Seconds") $DRI = $DRI + 1 ElseIf $m <> 1 And StringInStr($pst[$i], ".") <> 0 Then _FileWriteLog($Log, "DRU>ERROR>PST - File Copy>Failed to copy the file - >" & $pst[$i] & " Error value = " & $m) $DER = $DER + 1 EndIf Else _FileWriteLog($Log, "DRU>INFO>Favorites>" & "Not in to the copy loop" & $pst[$i]) EndIf Next Else _FileWriteLog($Log, "DRU>Error>PST>Variable PST does not return array value") EndIf GUICtrlSetState($PSTS, $GUI_HIDE) GUICtrlCreatePic($TickFile, 160, 220, 16, 16) GUICtrlCreateLabel("PST Files", 180, 220, 100, 30) EndIf If GUICtrlRead($ProfileBox) <> "" Then _GUICtrlRichEdit_WriteLine($iMemo, "Collecting Others folder details. Please wait.... " & @CRLF, "", "", 0x0000FF) If IsArray($GetpathArray) Then For $ta = 0 To UBound($GetpathArray) - 1 If $GetpathArray[$ta] <> "" Then $Trans = _RecFileListToArray($GetpathArray[$ta] & "", "*", 0, 1, 1) If IsArray($Trans) Then _GUICtrlRichEdit_WriteLine($iMemo, UBound($Trans) & " Files to be copied. Please wait... " & @CRLF, "", "", 0xFE2EF7) For $i = 0 To UBound($Trans) - 1 _FileWriteLog($Log, "DRU>INFO>Transfer>Source location>" & $GetpathArray[$ta] & "" & $Trans[$i]) _FileWriteLog($Log, "DRU>INFO>Transfer>Destination location>" & "C:" & $Trans[$i]) ; If StringInStr($Desktop[$i], ".") <> 0 Then $md = _LargeFileCopy($GetpathArray[$ta] & "" & $Trans[$i], "C:" & $Trans[$i], BitOR(1, 2, 8)) If $md = 1 Then _FileWriteLog($Log, "DRU>INFO>Transfer - File Copy> copied the file - " & $Trans[$i]) $DRI = $DRI + 1 ElseIf $md <> 1 Then _FileWriteLog($Log, "DRU>ERROR>Transfer - File Copy>Failed to copy the file - >" & $Trans[$i] & " Error value = " & @error) $DER = $DER + 1 EndIf ; Else ; _FileWriteLog($Log, "DRU>INFO>Desktop>" & "Not in to the copy loop" & $Desktop[$i]) ; EndIf Next Else _GUICtrlRichEdit_WriteLine($iMemo, UBound($Desktop) & " Files to be copied!" & @CRLF, "", "", 0x2E2EFE) _FileWriteLog($Log, "DRU>Error>Transfer>Variable Desktop does not return array value") EndIf EndIf Next Else _FileWriteLog($Log, "DRU>Error>Transfer>Variable Desktop does not return array value") EndIf EndIf Else GUICtrlSetState($iProgress_1, $GUI_HIDE) EndIf EndFunc ;==>process Func _check() If DriveGetType(GUICtrlRead($DrivePath)) <> "Fixed" And $msg = $StartButton Then ;MsgBox(48,"Source Drive Warning!","Source directory can not be a Network drive. Please select the correct drive.") GUICtrlSetData($ErrorLabel, "Source directory can not be a Network/Optical drive. Please select the correct drive.") GUICtrlSetColor($ErrorLabel, 0xff0000) GUICtrlSetState($ErrorLabel, $GUI_SHOW) _FileWriteLog($Log, "DRU>Warning>Source Drive Status>User Selected Network/Optical drive - !" & GUICtrlRead($DrivePath)) ElseIf (GUICtrlRead($DrivePath)) = "" And $msg = $StartButton Then GUICtrlSetData($ErrorLabel, "Source directory can not be Blank. Please select the correct drive.") GUICtrlSetColor($ErrorLabel, 0xff0000) GUICtrlSetState($ErrorLabel, $GUI_SHOW) _FileWriteLog($Log, "DRU>Warning>Source Drive Status>User Selected Blank drive - !" & GUICtrlRead($DrivePath)) Else GUICtrlSetData($ErrorLabel, "") If GUICtrlRead($ProfileBox) = "" And GUICtrlRead($DESK) <> 1 And GUICtrlRead($FAV) <> 1 And GUICtrlRead($OFF) <> 1 And GUICtrlRead($AVA) <> 1 And GUICtrlRead($CRYPTO) <> 1 And GUICtrlRead($PSTS) <> 1 And GUICtrlRead($Others) <> 1 And GUICtrlRead($Transfer) <> 1 And GUICtrlRead($Mydocs) <> 1 Then MsgBox(48, "Restor Option Warning!", "Atleast one option should be selected in Restore option") GUICtrlSetState($iProgress_1, $GUI_HIDE) _FileWriteLog($Log, "DRU>Warning>Options>Atleast one option should be selected - !") Else $ret = 1 EndIf EndIf EndFunc ;==>_check Func _GUICtrlRichEdit_WriteLine($hWnd, $sText, $iIncrement = 0, $sAttrib = "", $iColor = -1) ; Count the @CRLFs StringReplace(_GUICtrlRichEdit_GetText($hWnd, True), @CRLF, "") Local $iLines = @extended ; Adjust the text char count to account for the @CRLFs Local $iEndPoint = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) - $iLines ; Add new text _GUICtrlRichEdit_AppendText($hWnd, $sText & @CRLF) ; Select text between old and new end points _GUICtrlRichEdit_SetSel($hWnd, $iEndPoint, -1) ; Convert colour from RGB to BGR $iColor = Hex($iColor, 6) $iColor = '0x' & StringMid($iColor, 5, 2) & StringMid($iColor, 3, 2) & StringMid($iColor, 1, 2) ; Set colour If $iColor <> -1 Then _GUICtrlRichEdit_SetCharColor($hWnd, $iColor) ; Set size If $iIncrement <> 0 Then _GUICtrlRichEdit_ChangeFontSize($hWnd, $iIncrement) ; Set weight If $sAttrib <> "" Then _GUICtrlRichEdit_SetCharAttributes($hWnd, $sAttrib) ; Clear selection _GUICtrlRichEdit_Deselect($hWnd) EndFunc ;==>_GUICtrlRichEdit_WriteLine Func _TvCheckbox($hTvItem, $fTvCheck) ;-------------- Going up the tree ----------------------------------- _TvCheckboxParent($hTvItem, $fTvCheck) ;-------------- Going down the tree ----------------------------------- _TvCheckboxChild($hTvItem, $fTvCheck) ;-------------- Loopping to the function to get the detail of selected tree ----------------------------------- _TvGetpath($hTvItem, $fTvCheck) EndFunc ;==>_TvCheckbox Func _TvCheckboxChild($hTvItem, $fTvCheck) Local $hFirst, $hNext $hFirst = _GUICtrlTreeView_GetFirstChild($hTreeView, $hTvItem) If $hFirst Then $hNext = $hFirst While $hNext _GUICtrlTreeView_SetChecked($hTreeView, $hNext, $fTvCheck) If _GUICtrlTreeView_GetFirstChild($hTreeView, $hNext) Then _TvCheckboxChild($hNext, $fTvCheck) EndIf $hNext = _GUICtrlTreeView_GetNextSibling($hTreeView, $hNext) WEnd EndIf EndFunc ;==>_TvCheckboxChild Func _TvCheckboxParent($hTvItem, $fTvCheck) Local $hFirst, $hNext, $bCheckedFlag If $fTvCheck Then $hTvParent = _GUICtrlTreeView_GetParentHandle($hTreeView, $hTvItem) If $hTvParent = 0 Then _GUICtrlTreeView_SetChecked($hTreeView, $hTvItem, $fTvCheck) Else $hFirst = _GUICtrlTreeView_GetParentHandle($hTreeView, $hTvItem) If $hFirst Then $hNext = $hFirst _GUICtrlTreeView_SetChecked($hTreeView, $hNext, $fTvCheck) If _GUICtrlTreeView_GetParentHandle($hTreeView, $hNext) Then _TvCheckboxParent($hNext, $fTvCheck) EndIf EndIf EndIf Else $hTvParent = _GUICtrlTreeView_GetParentHandle($hTreeView, $hTvItem) If $hTvParent = 0 Then ; reached the top of the list _GUICtrlTreeView_SetChecked($hTreeView, $hTvItem, $fTvCheck) Else $hNext = $hTvParent ; check to see if any siblings are checked $hSibling = _GUICtrlTreeView_GetFirstChild($hTreeView, $hNext) $bCheckedFlag = True While $hSibling > 0 If _GUICtrlTreeView_GetChecked($hTreeView, $hSibling) Then $bCheckedFlag = False ExitLoop EndIf $hSibling = _GUICtrlTreeView_GetNextSibling($hTreeView, $hSibling) WEnd If $bCheckedFlag Then _GUICtrlTreeView_SetChecked($hTreeView, $hNext, $fTvCheck) EndIf If _GUICtrlTreeView_GetParentHandle($hTreeView, $hNext) Then _TvCheckboxParent($hNext, $fTvCheck) EndIf EndIf EndIf EndFunc ;==>_TvCheckboxParent Func WM_NOTIFY($hWnd, $msg, $wParam, $lParam) Local $tNMHDR, $IdFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $IdFrom = DllStructGetData($tNMHDR, "IdFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hTreeView Switch $iCode Case $NM_CLICK $fDblClk = True EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func about() MsgBox(64, "About", "Tool Name: Data Restoration Utlity" & @CRLF & @CRLF & @CRLF & "Software Used: Auto IT" & @CRLF & @CRLF & @CRLF & "For issue/Suggestions: Send an email to below EMAIL ID" & @CRLF & @CRLF & "syed.ibrahim@kcc.com") EndFunc ;==>about Func _TvGetpath($hTvItem, $fTvCheck) $GetpathArray[$z] = _GUICtrlTreeView_GetTree($hTreeView, $hTvItem) $z += 1 EndFunc ;==>_TvGetpath

Edited by Syed23, 01 September 2012 - 03:13 PM.

Thank you,Regards,K.Syed Ibrahim.

#17 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,318 posts

Posted 01 September 2012 - 03:49 PM

Syed23,

The problem is in line 169:
GUICtrlSetData($ProfileBox, $FileList[$i] & @CRLF)

You are adding a @CRLF to the folder name which makes the path false when the _RecFileListToArray UDF tests it. ;)

I mentioned error-checking - here is exactly what I did to find the problem:

- The return from the UDF was @error = 1 (Invalid Path) - which is what I thought it might be.

- When I tried to ConsoleWrite the path there was an added line in the return - checking the binary of the return showed an 0D0A at the end.

- Looking at how the combo was filled showed the problem.

See how easy that would have been for you to find for yourself had you done some proper errorchecking on the path as I suggested earlier? ;)

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#18 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 01 September 2012 - 06:20 PM

Syed23,

The problem is in line 169:

GUICtrlSetData($ProfileBox, $FileList[$i] & @CRLF)
You are adding a @CRLF to the folder name which makes the path false when the _RecFileListToArray UDF tests it. ;)

I mentioned error-checking - here is exactly what I did to find the problem:

- The return from the UDF was @error = 1 (Invalid Path) - which is what I thought it might be.

- When I tried to ConsoleWrite the path there was an added line in the return - checking the binary of the return showed an 0D0A at the end.

- Looking at how the combo was filled showed the problem.

See how easy that would have been for you to find for yourself had you done some proper errorchecking on the path as I suggested earlier? ;)

M23

Wow! Masters are always masters! to be honset i did not thought in that way to get the return value of the _RecFileListtoArray() function. Really i am stupid. But thanks for pointing out me. i will add it in my error trouble shooting checklist.. Thanks Melba23... you always rocks!!!
Thank you,Regards,K.Syed Ibrahim.

#19 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,318 posts

Posted 01 September 2012 - 07:10 PM

Syed23,

Always glad to help. :)

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users