Jump to content

Recommended Posts

Here is an another test result with updated code... :)

Path received:  Program Files (x86)
Path to expand: C:Program Files (x86)
Path received:  Program Files (x86)Microsoft Office
Path to expand: C:Program Files (x86)Microsoft Office
|

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to post
Share on other sites
  • Replies 75
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Syed23, Always happy to help. M23

  • Moderators

Syed23,

And there is the answer - _GUICtrlTreeView_GetTree is not returning what it should on your machine. I would expect it to return "Program Files (x86)|Microsoft Office" which the UDF would convert to "Program Files (x86)Microsoft Office". ;)

Now we come to the next question - why does it not do this. The final "|" in your return shows that the DataSeparationChar is still set at the default - my initial suspicion was that you had changed it. But it seems that your machine does not add the character into the path as it should. :(

I will go and investigate further. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
  • Moderators

Syed23,

Another test please: :)

#include <GuiTreeView.au3>
#include "RecFileListToArray.au3"

Global $cCFF_Expand_Dummy, $cCFF_DblClk_Dummy

Func _CFF_Choose($sTitle, $iW, $iH, $iX = -1, $iY = -1, $sRoot = "", $sFile_Mask = "*", $iDisplay = 0, $iMultiple = 0, $hParent = 0)

#region
    ; Check position
    If $iX = Default Then
        $iX = -1
    EndIf
    If $iY = Default Then
        $iY = -1
    EndIf

    ; Check path
    Switch $sRoot
        Case "", Default
            $sRoot = ""
        Case Else
            If Not FileExists($sRoot) Then
                Return SetError(1, 0, "")
            EndIf
            If StringRight($sRoot, 1) <> "" Then
                $sRoot &= ""
            EndIf
    EndSwitch

    ; Check FileMask
    If $sFile_Mask = Default Then
        $sFile_Mask = "*"
    EndIf

    ; Check Display
    ; Hide file extensions?
    Local $fShow_Ext = True
    If BitAnd($iDisplay, 16) Then
        $iDisplay -= 16
        ; Check that only one ext is specified
        StringReplace($sFile_Mask, ";", "")
        Local $iExt = @extended
        If $sFile_Mask <> "*.*" And $iExt = 0 Then
            ; File exts hidden
            $fShow_Ext = False
        EndIf
    EndIf
    ; Show hiden and system files
    Local $iHide_HS = 0
    If BitAnd($iDisplay, 4) Then
        $iHide_HS += 4
        $iDisplay -= 4
    EndIf
    If BitAnd($iDisplay, 8) Then
        $iHide_HS += 8
        $iDisplay -= 8
    EndIf
    ; Check valid parameter
    Switch $iDisplay
        Case 0 To 3
            ; Valid
        Case Else
            Return SetError(2, 0, "")
    EndSwitch

    ; Check selection type and list size
    Local $fSingle_Sel = False
    Local $iList_Percent = .2
    Switch $iMultiple
        Case 0, Default
            $fSingle_Sel = True
        Case 10 To 50
            $iList_Percent = .01 * $iMultiple
    EndSwitch

    ; Check parent
    Switch $hParent
        Case 0
        Case Else
            If Not IsHWnd($hParent) Then Return SetError(3, 0, "")
    EndSwitch

    ; Check for width and height minima and set button size
    Local $iButton_Width
    If $fSingle_Sel Then
        If $iW < 130 Then $iW = 130
        $iButton_Width = Int(($iW - 30) / 2)
    Else
        If $iW < 190 Then $iW = 190
        $iButton_Width = Int(($iW - 40) / 3)
    EndIf
    If $iButton_Width > 80 Then $iButton_Width = 80
    If $iH < 300 Then $iH = 300

    ; Create dialog
    Local $hCFF_Win = GUICreate($sTitle, $iW, $iH, $iX, $iY, 0x80C80000, -1, $hParent) ; BitOR($WS_POPUPWINDOW, $WS_CAPTION)
    If @error Then Return SetError(4, 0, "")
    GUISetBkColor(0xCECECE)

    ; Declare variables
    Local $hCan_Button, $cSel_Button = 9999, $cAdd_Button = 9999, $cRet_Button = 9999
    Local $cTreeView = 9999, $hTreeView = 9999, $hList = 9999, $hDrive_Combo = 9999
    Local $sCurrDrive = "", $sSelectedPath, $iList_Height, $iTV_Height, $sAddFile_List = ""

    ; Create buttons
    If $fSingle_Sel Then
        $cSel_Button = GUICtrlCreateButton("Select", $iW - ($iButton_Width + 10), $iH - 40, $iButton_Width, 30)
    Else
        $cAdd_Button = GUICtrlCreateButton("Add", 10, $iH - 40, $iButton_Width, 30)
        $cRet_Button = GUICtrlCreateButton("Return", $iW - ($iButton_Width + 10), $iH - 40, $iButton_Width, 30)
    EndIf
    $hCan_Button = GUICtrlCreateButton("Cancel", $iW - ($iButton_Width + 10) * 2, $iH - 40, $iButton_Width, 30)

    ; Create controls
    Select
        Case $sRoot And $fSingle_Sel ; TV only
            ; Create TV and hide
            $cTreeView = GUICtrlCreateTreeView(10, 10, $iW - 20, $iH - 60)
            $hTreeView = GUICtrlGetHandle($cTreeView)
            GUICtrlSetState(-1, 32) ; $GUI_HIDE

        Case Not $sRoot And $fSingle_Sel ; Combo and TV
            ; Create and fill Combo
            $hDrive_Combo = _CFF_Combo_Fill($iW)
            ; Create TV and hide
            $cTreeView = GUICtrlCreateTreeView(10, 40, $iW - 20, $iH - 90)
            $hTreeView = GUICtrlGetHandle($cTreeView)
            GUICtrlSetState(-1, 32) ; $GUI_HIDE

        Case $sRoot And Not $fSingle_Sel ; TV and List
            ; Calculate control heights
            $iList_Height = Int(($iH - 60) * $iList_Percent)
            If $iList_Height < 40 Then
                $iList_Height = 40
            EndIf
            $iTV_Height = $iH - $iList_Height - 60
            ; Create TV and hide
            $cTreeView = GUICtrlCreateTreeView(10, 10, $iW - 20, $iTV_Height)
            $hTreeView = GUICtrlGetHandle($cTreeView)
            GUICtrlSetState(-1, 32) ; $GUI_HIDE
            ; Create List
            $hList = GUICtrlCreateList("", 10, 10 + $iTV_Height, $iW - 20, $iList_Height, 0x00A04100) ;BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOSEL, $LBS_NOINTEGRALHEIGHT))

        Case Not $sRoot And Not $fSingle_Sel ; Combo, TV and List
            ; Calculate control heights
            $iList_Height = Int(($iH - 90) * $iList_Percent)
            If $iList_Height < 40 Then
                $iList_Height = 40
            EndIf
            $iTV_Height = $iH - $iList_Height - 90
            ; Create and fill Combo
            $hDrive_Combo = _CFF_Combo_Fill($iW)
            ; Create TV and hide
            $cTreeView = GUICtrlCreateTreeView(10, 40, $iW - 20, $iTV_Height)
            $hTreeView = GUICtrlGetHandle($cTreeView)
            GUICtrlSetState(-1, 32) ; $GUI_HIDE
            ; Create List
            $hList = GUICtrlCreateList("", 10, 40 + $iTV_Height, $iW - 20, $iList_Height, 0x00A04100) ;BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOSEL, $LBS_NOINTEGRALHEIGHT))
    EndSelect

    ; Create dummy control to fire when [+] clicked
    $cCFF_Expand_Dummy = GUICtrlCreateDummy()
    ; Create dummy control to for on DblClk
    $cCFF_DblClk_Dummy = GUICtrlCreateDummy()

    ; Display dialog
    GUISetState()

    If $sRoot Then
        ; If root folder specified then fill TV
        _CFF_Fill_Branch($hTreeView, $cTreeView, $sRoot, $iDisplay, $sFile_Mask, $fShow_Ext, $iHide_HS)
        ; Show TV
        GUICtrlSetState($cTreeView, 16) ; $GUI_SHOW
    EndIf

    ; Change to MessageLoop mode
    Local $nOldOpt = Opt('GUIOnEventMode', 0)

    #endregion

    While 1

        Switch GUIGetMsg()
            Case $hCan_Button, -3 ; $GUI_EVENT_CLOSE
                GUIDelete($hCFF_Win)
                ; Restore previous mode
                Opt('GUIOnEventMode', $nOldOpt)
                Return SetError(5, 0, "")

            Case $cCFF_DblClk_Dummy
                ; Check doubleclicks are permitted (not default for folders only)
                If $iDisplay <> 2 Then
                    ContinueCase
                EndIf

            Case $cSel_Button, $cAdd_Button
                ; Get item data
                Local $cItem = GUICtrlRead($cTreeView)
                Local $hItem = GUICtrlGetHandle($cItem)
                ; Determine item path
                $sSelectedPath = $sRoot & StringReplace(_GUICtrlTreeView_GetTree_Mod($hTreeView, $hItem), "|", "")
                ; Check path is a valid selection
                Switch $iDisplay
                    Case 2
                        ; Folders only
                    Case Else
                        ; Files only
                        StringReplace(FileGetAttrib($sSelectedPath), "D", "")
                        ; Is it a folder?
                        If @extended Then
                            $sSelectedPath = ""
                        EndIf
                        ; Hide extension?
                        If $fShow_Ext = False Then
                            $sSelectedPath &= StringTrimLeft($sFile_Mask, 1)
                        EndIf
                EndSwitch
                If $sSelectedPath Then
                    ; Valid item selected
                    If $fSingle_Sel Then
                        GUIDelete($hCFF_Win)
                        ; Restore previous mode
                        Opt('GUIOnEventMode', $nOldOpt)
                        ; Return valid path
                        Return $sSelectedPath
                    Else
                        ; Add to return string
                        $sAddFile_List &= $sSelectedPath & "|"
                        ; Add to onscreen list
                        GUICtrlSendMsg($hList, 0x0180, 0, $sSelectedPath) ; $LB_ADDSTRING
                        ; Scroll to bottom of list
                        GUICtrlSendMsg($hList, 0x197, GUICtrlSendMsg($hList, 0x18B, 0, 0) - 1, 0) ; $LB_SETTOPINDEX, $LB_GETCOUNT
                        ; Return focus to TV
                        GUICtrlSetState($cTreeView, 256) ; $GUI_FOCUS
                    EndIf
                EndIf

            Case $cRet_Button
                GUIDelete($hCFF_Win)
                ; Restore previous mode
                Opt('GUIOnEventMode', $nOldOpt)
                ; Remove final | from return string and return
                Return StringTrimRight($sAddFile_List, 1)

            Case $cCFF_Expand_Dummy
                ; Get expanded item hamdle
                $hItem = GUICtrlRead($cCFF_Expand_Dummy)
                If $hItem Then
                    ; Select item
                    _GUICtrlTreeView_ClickItem($hTreeView, $hItem)
                    ; Get expanded item data
                    $cItem = GUICtrlRead($cTreeView)
                    $hItem = GUICtrlGetHandle($cItem)
                    $sSelectedPath = $sRoot & StringReplace(_GUICtrlTreeView_GetTree_Mod($cTreeView, $hItem), "|", "")

                    ConsoleWrite("Path received:  " & _GUICtrlTreeView_GetTree_Mod($cTreeView, $hItem) & @CRLF)
                    ConsoleWrite("Path to expand: " & $sSelectedPath & @CRLF)

                    ; Check if dummy child exists or has already been filled
                    Local $hFirstChild = _GUICtrlTreeView_GetFirstChild($hTreeView, $hItem)
                    Local $sFirstChild = _GUICtrlTreeView_GetText($hTreeView, $hFirstChild)
                    ; If dummy child exists
                    If $sFirstChild = "" Then
                        ; Fill with content
                        _CFF_Fill_Branch($hTreeView, $cItem, $sSelectedPath, $iDisplay, $sFile_Mask, $fShow_Ext, $iHide_HS)
                        ; Delete the dummy
                        _GUICtrlTreeView_Delete($hTreeView, $hFirstChild)
                    ;Else
                        ; Either already filled or empty
                    EndIf
                    ; Clear the flag to reactivate the handler
                    GUICtrlSendToDummy($cCFF_Expand_Dummy, 0)
                EndIf

            Case $hDrive_Combo
                If GUICtrlRead($hDrive_Combo) <> $sCurrDrive Then
                    ; Get drive chosen
                    $sCurrDrive = GUICtrlRead($hDrive_Combo)
                    If $sRoot Then
                        ; Delete current content
                        _GUICtrlTreeView_DeleteAll($hTreeView)
                    Else
                        ; Show TV
                        GUICtrlSetState($cTreeView, 16) ; $GUI_SHOW
                    EndIf
                    ; Set root path
                    $sRoot = $sCurrDrive & ""
                    ; Fill TV
                    _CFF_Fill_Branch($hTreeView, $cTreeView, $sRoot, $iDisplay, $sFile_Mask, $fShow_Ext, $iHide_HS)
                EndIf

        EndSwitch

    WEnd

EndFunc   ;==>_CFF_Choose

Func _CFF_RegMsg()

    Return GUIRegisterMsg(0x004E, "_CFF_WM_NOTIFY_Handler") ; $WM_NOTIFY

EndFunc   ;==>_CFF_RegMsg

Func _CFF_WM_NOTIFY_Handler($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam

    Local $tStruct = DllStructCreate("struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct;" & _
        "uint Action;struct;uint OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & _
        "ptr OldText;int OldTextMax;int OldImage;int OldSelectedImage;int OldChildren;lparam OldParam;endstruct;" & _
        "struct;uint NewMask;handle NewhItem;uint NewState;uint NewStateMask;" & _
        "ptr NewText;int NewTextMax;int NewImage;int NewSelectedImage;int NewChildren;lparam NewParam;endstruct;" & _
        "struct;long PointX;long PointY;endstruct", $lParam)
    Local $hItem = DllStructGetData($tStruct, 'NewhItem')
    Local $ID = DllStructGetData($tStruct, 'Code')
    Switch $ID
        Case 0xFFFFFFFD ; $NM_DBLCLK
            ; Fire the dummy control
            GUICtrlSendToDummy($cCFF_DblClk_Dummy)
        Case $TVN_ITEMEXPANDEDW, $TVN_ITEMEXPANDEDA
            ; Check that expansion is not ongoing
            If GUICtrlRead($cCFF_Expand_Dummy) = 0 Then
                ; Fire the dummy control
                GUICtrlSendToDummy($cCFF_Expand_Dummy, $hItem)
            EndIf
    EndSwitch

EndFunc   ;==>_CFF_WM_NOTIFY_Handler

Func _CFF_Combo_Fill($iW)

    Local $iInset = Int(($iW - 170) / 2)

    GUICtrlCreateLabel("Select Drive:", 10 + $iInset, 15, 65, 20)
    Local $hCombo = GUICtrlCreateCombo("", 75 + $iInset, 10, 50, 20)
    Local $aDrives = DriveGetDrive("ALL")
    For $i = 1 To $aDrives[0]
        ; Only display ready drives
        If DriveStatus($aDrives[$i] & '') <> "NOTREADY" Then GUICtrlSetData($hCombo, StringUpper($aDrives[$i]))
    Next
    Return $hCombo

EndFunc   ;==>_CFF_Combo_Fill

Func _CFF_Fill_Branch($hTV, $cParent, $sPath, $iDisplay, $sFile_Mask, $fShow_Ext, $iHide_HS)

    Local $sItem, $cItem, $hSearch, $FFound = False

    ;ConsoleWrite("Passed path = " & $sPath & @CRLF)

    If StringRight($sPath, 1) <> "" Then
        $sPath &= ""
    EndIf

    ;ConsoleWrite("Used path  = " & $sPath & @CRLF)

    _GUICtrlTreeView_BeginUpdate($hTV)
    Switch $iDisplay
        Case 0, 2, 3

            ;ConsoleWrite("! Folder listing: " & $sPath & " - " & 2 + $iHide_HS & @CRLF)

            ; List folders
            Local $aContent = _RecFileListToArray($sPath, "*", 2 + $iHide_HS, 0, 1, 1)


            If IsArray($aContent) Then

                ;ConsoleWrite("+ Expanding: " & $sPath & " - found " & $aContent[0] & " folders" & @CRLF)

                For $i = 1 To $aContent[0]
                    ; Remove trailing  if needed
                    $sItem = $aContent[$i]
                    If StringRight($sItem, 1) = "" Then
                        $sItem = StringTrimRight($sItem, 1)
                    EndIf
                    ; Create item
                    $cItem = GUICtrlCreateTreeViewItem($sItem, $cParent)
                    ; Look for content within the folder
                    FileChangeDir($sPath & $aContent[$i])
                    $hSearch = FileFindFirstFile("*.*")
                    ; If there is something
                    If $hSearch <> -1 Then

                        ;If StringInStr( $sPath & $aContent[$i], "Microsoft Office") Then
                            ;ConsoleWrite("> Found something within: " & $sPath & $aContent[$i] & @CRLF)
                        ;EndIf

                        ; Set flag
                        $fFound = True
                        ; Need to determine type of content?
                        Switch $iDisplay
                            Case 0 ; Either folder or file
                                ; Create dummy child to force [+] display
                                GUICtrlCreateTreeViewItem("", $cItem)
                            Case Else
                                While 1
                                    FileFindNextFile($hSearch)
                                    ; End of content
                                    If @error Then ExitLoop
                                    Local $iExtended = @extended
                                    Switch $iDisplay
                                        Case 1 ; Files only
                                            If Not $iExtended Then
                                                ; Found file
                                                GUICtrlCreateTreeViewItem("", $cItem)
                                                ; No need to look further
                                                ExitLoop
                                            EndIf
                                        Case Else ; Folders only
                                            If $iExtended Then
                                                ; Found folder
                                                GUICtrlCreateTreeViewItem("", $cItem)
                                                ; No need to look further
                                                ExitLoop
                                            EndIf
                                    EndSwitch
                                WEnd
                                ; Close search
                                FileClose($hSearch)
                        EndSwitch
                    EndIf
                    FileChangeDir(@ScriptDir)
                Next
            EndIf
    EndSwitch
    Switch $iDisplay
        Case 0, 1
            ; List files
            $aContent = _RecFileListToArray($sPath, $sFile_Mask, 1 + $iHide_HS, 0, 1)

            ;ConsoleWrite("! File listing: " & $sPath & " - " & 1 + $iHide_HS & @CRLF)

            If IsArray($aContent) Then

                ;ConsoleWrite("+ Expanding: " & $sPath & " - found " & $aContent[0] & " files" & @CRLF)

                ; Set flag
                $FFound = True
                For $i = 1 To $aContent[0]
                    $sItem = $aContent[$i]
                    ; Remove extension if required
                    If Not $fShow_Ext Then
                        $sItem = StringRegExpReplace($sItem, "(.*)..*", "$1")
                    EndIf
                    ; Create item
                    GUICtrlCreateTreeViewItem($sItem, $cParent)
                Next
            EndIf
    EndSwitch
    _GUICtrlTreeView_EndUpdate($hTV)

    Return $fFound

EndFunc   ;==>_CFF_Fill_Branch

Func _GUICtrlTreeView_GetTree_Mod($hWnd, $hItem = 0)
    If $Debug_TV Then __UDF_ValidateClassName($hWnd, $__TREEVIEWCONSTANT_ClassName)

    If $hItem = 0 Then
        $hItem = 0x00000000
    Else
        If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
    EndIf
    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

    Local $szPath = ""

    If $hItem = 0x00000000 Then $hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CARET, 0, 0, "wparam", "handle", "handle")
    If $hItem <> 0x00000000 Then
        $szPath = _GUICtrlTreeView_GetText($hWnd, $hItem)

        Local $hParent, $sSeparator = Opt("GUIDataSeparatorChar")

        ConsoleWrite($sSeparator & @CRLF)

        Do; Get now the parent item handle if there is one
            $hParent = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem, 0, "wparam", "handle", "handle")
            If $hParent <> 0x00000000 Then $szPath = _GUICtrlTreeView_GetText($hWnd, $hParent) & $sSeparator & $szPath

            ConsoleWrite($szPath & @CRLF)

            $hItem = $hParent
        Until $hItem = 0x00000000
    EndIf

    Return $szPath
EndFunc   ;==>_GUICtrlTreeView_GetTree_Mod

_CFF_RegMsg()

$sRet = _CFF_Choose("Syed23 Test 5", 300, 500, -1, -1, "", 0)

Me:

|
Program Files
|
Program Files
Path received:  Program Files
Path to expand: C:Program Files
|
Program Files|Microsoft Office
Program Files|Microsoft Office
|
Program Files|Microsoft Office
Program Files|Microsoft Office
|
Program Files|Microsoft Office
Program Files|Microsoft Office
Path received:  Program Files|Microsoft Office
Path to expand: C:Program FilesMicrosoft Office

Having fun? I am! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

Melba23,

you are a star! now it works perfect! may i know what you have changed?:D tested with Microsoft Office folder and users folder as well. It is working awesome!

|
Program Files (x86)
|
Program Files (x86)
Path received: Program Files (x86)
Path to expand: C:Program Files (x86)
|
Program Files (x86)|Microsoft Office
Program Files (x86)|Microsoft Office
|
Program Files (x86)|Microsoft Office
Program Files (x86)|Microsoft Office
Path received: Program Files (x86)|Microsoft Office
Path to expand: C:Program Files (x86)Microsoft Office
|
Microsoft Office|Office14
Program Files (x86)|Microsoft Office|Office14
Program Files (x86)|Microsoft Office|Office14
Edited by Syed23

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to post
Share on other sites
  • Moderators

Syed23,

Congratulations might be a trifle premature - all I have done is to use exactly the same code to read the tree as in the standard GUITreeView UDF, but as a standalone function. The question now is why the code worked in that case and not when in the UDF? :wacko:

So yet another test to see if this is indeed the answer: ;)

#include <GuiTreeView.au3>
#include "RecFileListToArray.au3"

Global $cCFF_Expand_Dummy, $cCFF_DblClk_Dummy

Func _CFF_Choose($sTitle, $iW, $iH, $iX = -1, $iY = -1, $sRoot = "", $sFile_Mask = "*", $iDisplay = 0, $iMultiple = 0, $hParent = 0)

#region
    ; Check position
    If $iX = Default Then
        $iX = -1
    EndIf
    If $iY = Default Then
        $iY = -1
    EndIf

    ; Check path
    Switch $sRoot
        Case "", Default
            $sRoot = ""
        Case Else
            If Not FileExists($sRoot) Then
                Return SetError(1, 0, "")
            EndIf
            If StringRight($sRoot, 1) <> "" Then
                $sRoot &= ""
            EndIf
    EndSwitch

    ; Check FileMask
    If $sFile_Mask = Default Then
        $sFile_Mask = "*"
    EndIf

    ; Check Display
    ; Hide file extensions?
    Local $fShow_Ext = True
    If BitAnd($iDisplay, 16) Then
        $iDisplay -= 16
        ; Check that only one ext is specified
        StringReplace($sFile_Mask, ";", "")
        Local $iExt = @extended
        If $sFile_Mask <> "*.*" And $iExt = 0 Then
            ; File exts hidden
            $fShow_Ext = False
        EndIf
    EndIf
    ; Show hiden and system files
    Local $iHide_HS = 0
    If BitAnd($iDisplay, 4) Then
        $iHide_HS += 4
        $iDisplay -= 4
    EndIf
    If BitAnd($iDisplay, 8) Then
        $iHide_HS += 8
        $iDisplay -= 8
    EndIf
    ; Check valid parameter
    Switch $iDisplay
        Case 0 To 3
            ; Valid
        Case Else
            Return SetError(2, 0, "")
    EndSwitch

    ; Check selection type and list size
    Local $fSingle_Sel = False
    Local $iList_Percent = .2
    Switch $iMultiple
        Case 0, Default
            $fSingle_Sel = True
        Case 10 To 50
            $iList_Percent = .01 * $iMultiple
    EndSwitch

    ; Check parent
    Switch $hParent
        Case 0
        Case Else
            If Not IsHWnd($hParent) Then Return SetError(3, 0, "")
    EndSwitch

    ; Check for width and height minima and set button size
    Local $iButton_Width
    If $fSingle_Sel Then
        If $iW < 130 Then $iW = 130
        $iButton_Width = Int(($iW - 30) / 2)
    Else
        If $iW < 190 Then $iW = 190
        $iButton_Width = Int(($iW - 40) / 3)
    EndIf
    If $iButton_Width > 80 Then $iButton_Width = 80
    If $iH < 300 Then $iH = 300

    ; Create dialog
    Local $hCFF_Win = GUICreate($sTitle, $iW, $iH, $iX, $iY, 0x80C80000, -1, $hParent) ; BitOR($WS_POPUPWINDOW, $WS_CAPTION)
    If @error Then Return SetError(4, 0, "")
    GUISetBkColor(0xCECECE)

    ; Declare variables
    Local $hCan_Button, $cSel_Button = 9999, $cAdd_Button = 9999, $cRet_Button = 9999
    Local $cTreeView = 9999, $hTreeView = 9999, $hList = 9999, $hDrive_Combo = 9999
    Local $sCurrDrive = "", $sSelectedPath, $iList_Height, $iTV_Height, $sAddFile_List = ""

    ; Create buttons
    If $fSingle_Sel Then
        $cSel_Button = GUICtrlCreateButton("Select", $iW - ($iButton_Width + 10), $iH - 40, $iButton_Width, 30)
    Else
        $cAdd_Button = GUICtrlCreateButton("Add", 10, $iH - 40, $iButton_Width, 30)
        $cRet_Button = GUICtrlCreateButton("Return", $iW - ($iButton_Width + 10), $iH - 40, $iButton_Width, 30)
    EndIf
    $hCan_Button = GUICtrlCreateButton("Cancel", $iW - ($iButton_Width + 10) * 2, $iH - 40, $iButton_Width, 30)

    ; Create controls
    Select
        Case $sRoot And $fSingle_Sel ; TV only
            ; Create TV and hide
            $cTreeView = GUICtrlCreateTreeView(10, 10, $iW - 20, $iH - 60)
            $hTreeView = GUICtrlGetHandle($cTreeView)
            GUICtrlSetState(-1, 32) ; $GUI_HIDE

        Case Not $sRoot And $fSingle_Sel ; Combo and TV
            ; Create and fill Combo
            $hDrive_Combo = _CFF_Combo_Fill($iW)
            ; Create TV and hide
            $cTreeView = GUICtrlCreateTreeView(10, 40, $iW - 20, $iH - 90)
            $hTreeView = GUICtrlGetHandle($cTreeView)
            GUICtrlSetState(-1, 32) ; $GUI_HIDE

        Case $sRoot And Not $fSingle_Sel ; TV and List
            ; Calculate control heights
            $iList_Height = Int(($iH - 60) * $iList_Percent)
            If $iList_Height < 40 Then
                $iList_Height = 40
            EndIf
            $iTV_Height = $iH - $iList_Height - 60
            ; Create TV and hide
            $cTreeView = GUICtrlCreateTreeView(10, 10, $iW - 20, $iTV_Height)
            $hTreeView = GUICtrlGetHandle($cTreeView)
            GUICtrlSetState(-1, 32) ; $GUI_HIDE
            ; Create List
            $hList = GUICtrlCreateList("", 10, 10 + $iTV_Height, $iW - 20, $iList_Height, 0x00A04100) ;BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOSEL, $LBS_NOINTEGRALHEIGHT))

        Case Not $sRoot And Not $fSingle_Sel ; Combo, TV and List
            ; Calculate control heights
            $iList_Height = Int(($iH - 90) * $iList_Percent)
            If $iList_Height < 40 Then
                $iList_Height = 40
            EndIf
            $iTV_Height = $iH - $iList_Height - 90
            ; Create and fill Combo
            $hDrive_Combo = _CFF_Combo_Fill($iW)
            ; Create TV and hide
            $cTreeView = GUICtrlCreateTreeView(10, 40, $iW - 20, $iTV_Height)
            $hTreeView = GUICtrlGetHandle($cTreeView)
            GUICtrlSetState(-1, 32) ; $GUI_HIDE
            ; Create List
            $hList = GUICtrlCreateList("", 10, 40 + $iTV_Height, $iW - 20, $iList_Height, 0x00A04100) ;BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOSEL, $LBS_NOINTEGRALHEIGHT))
    EndSelect

    ; Create dummy control to fire when [+] clicked
    $cCFF_Expand_Dummy = GUICtrlCreateDummy()
    ; Create dummy control to for on DblClk
    $cCFF_DblClk_Dummy = GUICtrlCreateDummy()

    ; Display dialog
    GUISetState()

    If $sRoot Then
        ; If root folder specified then fill TV
        _CFF_Fill_Branch($hTreeView, $cTreeView, $sRoot, $iDisplay, $sFile_Mask, $fShow_Ext, $iHide_HS)
        ; Show TV
        GUICtrlSetState($cTreeView, 16) ; $GUI_SHOW
    EndIf

    ; Change to MessageLoop mode
    Local $nOldOpt = Opt('GUIOnEventMode', 0)

    #endregion

    While 1

        Switch GUIGetMsg()
            Case $hCan_Button, -3 ; $GUI_EVENT_CLOSE
                GUIDelete($hCFF_Win)
                ; Restore previous mode
                Opt('GUIOnEventMode', $nOldOpt)
                Return SetError(5, 0, "")

            Case $cCFF_DblClk_Dummy
                ; Check doubleclicks are permitted (not default for folders only)
                If $iDisplay <> 2 Then
                    ContinueCase
                EndIf

            Case $cSel_Button, $cAdd_Button
                ; Get item data
                Local $cItem = GUICtrlRead($cTreeView)
                Local $hItem = GUICtrlGetHandle($cItem)
                ; Determine item path
                $sSelectedPath = $sRoot & StringReplace(_GUICtrlTreeView_GetTree_Mod($hTreeView, $hItem), "|", "")
                ; Check path is a valid selection
                Switch $iDisplay
                    Case 2
                        ; Folders only
                    Case Else
                        ; Files only
                        StringReplace(FileGetAttrib($sSelectedPath), "D", "")
                        ; Is it a folder?
                        If @extended Then
                            $sSelectedPath = ""
                        EndIf
                        ; Hide extension?
                        If $fShow_Ext = False Then
                            $sSelectedPath &= StringTrimLeft($sFile_Mask, 1)
                        EndIf
                EndSwitch
                If $sSelectedPath Then
                    ; Valid item selected
                    If $fSingle_Sel Then
                        GUIDelete($hCFF_Win)
                        ; Restore previous mode
                        Opt('GUIOnEventMode', $nOldOpt)
                        ; Return valid path
                        Return $sSelectedPath
                    Else
                        ; Add to return string
                        $sAddFile_List &= $sSelectedPath & "|"
                        ; Add to onscreen list
                        GUICtrlSendMsg($hList, 0x0180, 0, $sSelectedPath) ; $LB_ADDSTRING
                        ; Scroll to bottom of list
                        GUICtrlSendMsg($hList, 0x197, GUICtrlSendMsg($hList, 0x18B, 0, 0) - 1, 0) ; $LB_SETTOPINDEX, $LB_GETCOUNT
                        ; Return focus to TV
                        GUICtrlSetState($cTreeView, 256) ; $GUI_FOCUS
                    EndIf
                EndIf

            Case $cRet_Button
                GUIDelete($hCFF_Win)
                ; Restore previous mode
                Opt('GUIOnEventMode', $nOldOpt)
                ; Remove final | from return string and return
                Return StringTrimRight($sAddFile_List, 1)

            Case $cCFF_Expand_Dummy
                ; Get expanded item hamdle
                $hItem = GUICtrlRead($cCFF_Expand_Dummy)
                If $hItem Then
                    ; Select item
                    _GUICtrlTreeView_ClickItem($hTreeView, $hItem)
                    ; Get expanded item data
                    $cItem = GUICtrlRead($cTreeView)
                    $hItem = GUICtrlGetHandle($cItem)
                    $sSelectedPath = $sRoot & StringReplace(_GUICtrlTreeView_GetTree_Mod($cTreeView, $hItem), "|", "")

                    ConsoleWrite("Path received Org:  " & _GUICtrlTreeView_GetTree($cTreeView, $hItem) & @CRLF)
                    ConsoleWrite("Path received Mod:  " & _GUICtrlTreeView_GetTree_Mod($cTreeView, $hItem) & @CRLF)


                    ; Check if dummy child exists or has already been filled
                    Local $hFirstChild = _GUICtrlTreeView_GetFirstChild($hTreeView, $hItem)
                    Local $sFirstChild = _GUICtrlTreeView_GetText($hTreeView, $hFirstChild)
                    ; If dummy child exists
                    If $sFirstChild = "" Then
                        ; Fill with content
                        _CFF_Fill_Branch($hTreeView, $cItem, $sSelectedPath, $iDisplay, $sFile_Mask, $fShow_Ext, $iHide_HS)
                        ; Delete the dummy
                        _GUICtrlTreeView_Delete($hTreeView, $hFirstChild)
                    ;Else
                        ; Either already filled or empty
                    EndIf
                    ; Clear the flag to reactivate the handler
                    GUICtrlSendToDummy($cCFF_Expand_Dummy, 0)
                EndIf

            Case $hDrive_Combo
                If GUICtrlRead($hDrive_Combo) <> $sCurrDrive Then
                    ; Get drive chosen
                    $sCurrDrive = GUICtrlRead($hDrive_Combo)
                    If $sRoot Then
                        ; Delete current content
                        _GUICtrlTreeView_DeleteAll($hTreeView)
                    Else
                        ; Show TV
                        GUICtrlSetState($cTreeView, 16) ; $GUI_SHOW
                    EndIf
                    ; Set root path
                    $sRoot = $sCurrDrive & ""
                    ; Fill TV
                    _CFF_Fill_Branch($hTreeView, $cTreeView, $sRoot, $iDisplay, $sFile_Mask, $fShow_Ext, $iHide_HS)
                EndIf

        EndSwitch

    WEnd

EndFunc   ;==>_CFF_Choose

Func _CFF_RegMsg()

    Return GUIRegisterMsg(0x004E, "_CFF_WM_NOTIFY_Handler") ; $WM_NOTIFY

EndFunc   ;==>_CFF_RegMsg

Func _CFF_WM_NOTIFY_Handler($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam

    Local $tStruct = DllStructCreate("struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct;" & _
        "uint Action;struct;uint OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & _
        "ptr OldText;int OldTextMax;int OldImage;int OldSelectedImage;int OldChildren;lparam OldParam;endstruct;" & _
        "struct;uint NewMask;handle NewhItem;uint NewState;uint NewStateMask;" & _
        "ptr NewText;int NewTextMax;int NewImage;int NewSelectedImage;int NewChildren;lparam NewParam;endstruct;" & _
        "struct;long PointX;long PointY;endstruct", $lParam)
    Local $hItem = DllStructGetData($tStruct, 'NewhItem')
    Local $ID = DllStructGetData($tStruct, 'Code')
    Switch $ID
        Case 0xFFFFFFFD ; $NM_DBLCLK
            ; Fire the dummy control
            GUICtrlSendToDummy($cCFF_DblClk_Dummy)
        Case $TVN_ITEMEXPANDEDW, $TVN_ITEMEXPANDEDA
            ; Check that expansion is not ongoing
            If GUICtrlRead($cCFF_Expand_Dummy) = 0 Then
                ; Fire the dummy control
                GUICtrlSendToDummy($cCFF_Expand_Dummy, $hItem)
            EndIf
    EndSwitch

EndFunc   ;==>_CFF_WM_NOTIFY_Handler

Func _CFF_Combo_Fill($iW)

    Local $iInset = Int(($iW - 170) / 2)

    GUICtrlCreateLabel("Select Drive:", 10 + $iInset, 15, 65, 20)
    Local $hCombo = GUICtrlCreateCombo("", 75 + $iInset, 10, 50, 20)
    Local $aDrives = DriveGetDrive("ALL")
    For $i = 1 To $aDrives[0]
        ; Only display ready drives
        If DriveStatus($aDrives[$i] & '') <> "NOTREADY" Then GUICtrlSetData($hCombo, StringUpper($aDrives[$i]))
    Next
    Return $hCombo

EndFunc   ;==>_CFF_Combo_Fill

Func _CFF_Fill_Branch($hTV, $cParent, $sPath, $iDisplay, $sFile_Mask, $fShow_Ext, $iHide_HS)

    Local $sItem, $cItem, $hSearch, $FFound = False

    If StringRight($sPath, 1) <> "" Then
        $sPath &= ""
    EndIf

    _GUICtrlTreeView_BeginUpdate($hTV)
    Switch $iDisplay
        Case 0, 2, 3
            ; List folders
            Local $aContent = _RecFileListToArray($sPath, "*", 2 + $iHide_HS, 0, 1, 1)
            If IsArray($aContent) Then
                For $i = 1 To $aContent[0]
                    ; Remove trailing  if needed
                    $sItem = $aContent[$i]
                    If StringRight($sItem, 1) = "" Then
                        $sItem = StringTrimRight($sItem, 1)
                    EndIf
                    ; Create item
                    $cItem = GUICtrlCreateTreeViewItem($sItem, $cParent)
                    ; Look for content within the folder
                    FileChangeDir($sPath & $aContent[$i])
                    $hSearch = FileFindFirstFile("*.*")
                    ; If there is something
                    If $hSearch <> -1 Then
                        ; Set flag
                        $fFound = True
                        ; Need to determine type of content?
                        Switch $iDisplay
                            Case 0 ; Either folder or file
                                ; Create dummy child to force [+] display
                                GUICtrlCreateTreeViewItem("", $cItem)
                            Case Else
                                While 1
                                    FileFindNextFile($hSearch)
                                    ; End of content
                                    If @error Then ExitLoop
                                    Local $iExtended = @extended
                                    Switch $iDisplay
                                        Case 1 ; Files only
                                            If Not $iExtended Then
                                                ; Found file
                                                GUICtrlCreateTreeViewItem("", $cItem)
                                                ; No need to look further
                                                ExitLoop
                                            EndIf
                                        Case Else ; Folders only
                                            If $iExtended Then
                                                ; Found folder
                                                GUICtrlCreateTreeViewItem("", $cItem)
                                                ; No need to look further
                                                ExitLoop
                                            EndIf
                                    EndSwitch
                                WEnd
                                ; Close search
                                FileClose($hSearch)
                        EndSwitch
                    EndIf
                    FileChangeDir(@ScriptDir)
                Next
            EndIf
    EndSwitch
    Switch $iDisplay
        Case 0, 1
            ; List files
            $aContent = _RecFileListToArray($sPath, $sFile_Mask, 1 + $iHide_HS, 0, 1)
            If IsArray($aContent) Then
                ; Set flag
                $FFound = True
                For $i = 1 To $aContent[0]
                    $sItem = $aContent[$i]
                    ; Remove extension if required
                    If Not $fShow_Ext Then
                        $sItem = StringRegExpReplace($sItem, "(.*)..*", "$1")
                    EndIf
                    ; Create item
                    GUICtrlCreateTreeViewItem($sItem, $cParent)
                Next
            EndIf
    EndSwitch
    _GUICtrlTreeView_EndUpdate($hTV)

    Return $fFound

EndFunc   ;==>_CFF_Fill_Branch

Func _GUICtrlTreeView_GetTree_Mod($hWnd, $hItem = 0)
    If $Debug_TV Then __UDF_ValidateClassName($hWnd, $__TREEVIEWCONSTANT_ClassName)

    If $hItem = 0 Then
        $hItem = 0x00000000
    Else
        If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
    EndIf
    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

    Local $szPath = ""

    If $hItem = 0x00000000 Then $hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CARET, 0, 0, "wparam", "handle", "handle")
    If $hItem <> 0x00000000 Then
        $szPath = _GUICtrlTreeView_GetText($hWnd, $hItem)

        Local $hParent, $sSeparator = Opt("GUIDataSeparatorChar")
        Do; Get now the parent item handle if there is one
            $hParent = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem, 0, "wparam", "handle", "handle")
            If $hParent <> 0x00000000 Then $szPath = _GUICtrlTreeView_GetText($hWnd, $hParent) & $sSeparator & $szPath
            $hItem = $hParent
        Until $hItem = 0x00000000
    EndIf

    Return $szPath
EndFunc   ;==>_GUICtrlTreeView_GetTree_Mod

_CFF_RegMsg()

$sRet = _CFF_Choose("Syed23 Test 6", 300, 500, -1, -1, "", 0)

My return:

Path received Org:  Program Files
Path received Mod:  Program Files
Path received Org:  Program Files|Microsoft Office
Path received Mod:  Program Files|Microsoft Office
Path received Org:  Program Files|Microsoft Office|Office
Path received Mod:  Program Files|Microsoft Office|Office

Then please open your {Autoit path}IncludeGuiTreeView.au3 file, look for the _GUICtrlTreeView_GetTree function, and post a copy of teh code so that I can see if there is something different about your copy. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

Here is my return value for the test: :)

Path received Org:  Program Files (x86)
Path received Mod:  Program Files (x86)
Path received Org:  Program Files (x86)AutoIt3
Path received Mod:  Program Files (x86)|AutoIt3
Path received Org:  Program Files (x86)AutoIt3Include
Path received Mod:  Program Files (x86)|AutoIt3|Include

and the code where you requested is mentioned beolow :)

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlTreeView_GetTree
; Description ...: Retrieve all items text
; Syntax.........: _GUICtrlTreeView_GetTree($hWnd, $hItem)
; Parameters ....: $hWnd  - Handle to the control
;                  $hItem - item ID/handle
; Return values .: Success      - Tree Path of Item
;                  Failure      - Empty string
; Author ........: Gary Frost (gafrost), Holger Kotsch
; Modified.......: Gary Frost (gafrost)
; Remarks .......: Use Opt("GUIDataSeparatorChar", param) to change the separator char used
;                  If $hItem is 0 then an attempt to use current selected is used
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _GUICtrlTreeView_GetTree($hWnd, $hItem = 0)
If $Debug_TV Then __UDF_ValidateClassName($hWnd, $__TREEVIEWCONSTANT_ClassName)

If $hItem = 0 Then
$hItem = 0x00000000
Else
If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
EndIf
If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

Local $szPath = ""

If $hItem = 0x00000000 Then $hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CARET, 0, 0, "wparam", "handle", "handle")
If $hItem <> 0x00000000 Then
$szPath = _GUICtrlTreeView_GetText($hWnd, $hItem)

Local $hParent, $sSeparator = Opt("GUIDataSeparatorChar")
Do; Get now the parent item handle if there is one
$hParent = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem, 0, "wparam", "handle", "handle")
If $hParent <> 0x00000000 Then $szPath = _GUICtrlTreeView_GetText($hWnd, $hParent) & $szPath
$hItem = $hParent
Until $hItem = 0x00000000
EndIf

Return $szPath
EndFunc   ;==>_GUICtrlTreeView_GetTree

Over to you ... :D

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to post
Share on other sites
  • Moderators

Syed23.

And there we have the final answer - your copy of that function is not the same as the one I have in the 3.3.8.1, 3.3.9.5 beta and the latest alpha releases. :o

You have this line:

If $hParent <> 0x00000000 Then $szPath = _GUICtrlTreeView_GetText($hWnd, $hParent) & $szPath

whereas in all the versions I have it reads:

If $hParent <> 0x00000000 Then $szPath = _GUICtrlTreeView_GetText($hWnd, $hParent) & $sSeparator & $szPath

Your version was not adding the DataSeparationCharacter into in the path and this meant that the return was not correctly formatted and the UDF errored on an invalid path parameter. I find it very interesting that all the machines on which you tested the UDF had the same problem. From where did you download your AutoIt installation? :huh:

I would recommend reinstalling AutoIt using the download from this site. Once you have done so, check that function again to make sure that yuo have the correct version. Then you should have no problem using the UDF. :)

M23

P.S. I am working on a version of the UDF which will easily permit you to integrate the treeview into your own GUI as you asked much earlier in the thread. Be patient - one reason I am not very advanced on that project is that I spent most of yesterday trying to solve your problem. :P

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
  • Moderators

Syed23,

Have you reinstalled AutoIt as I suggested? And do you now have the correct version of the function? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

Yes i have downloaded and installed it from the Autoit --> Downloads page... and tested the ChooseFileFolderEx.aue that works perfect :) Thanks for finding out my mistake :D

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to post
Share on other sites
  • Moderators

Syed23,

Do not forget that you need to reinstall on those other machines where you also ran into problems. ;)

I am glad we managed to find out what was wrong in the end - thank you for all the testing. :)

M23

Edited by Melba23
Added a "not"

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
  • Moderators

Syed23,

Check out the ChooseFileFolder thread for a beta version of the new UDF. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

Hi Melba23,

I just created CFF_Embeded.au3 and copied to Include folders then i have tried your example on my pc by selecting drives nothing is listing in the empty box. am i doing something wrong? :(

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to post
Share on other sites
  • Moderators

Syed23,

am i doing something wrong?

If you named the file "CFF_Embedded.au3" then "Yes" - it should be called "CFF_Embed.au3" as indicated in the example. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

sorry that was my spelling mistake i did as you said on example but nothing was listing for me when i select the drives.. i am just confused :huh:

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to post
Share on other sites
  • Moderators

Syed23,

You can only fill one TreeView at a time - the function is blocking and the combos will only action if you are back in the main loop. Are you trying to fill all 3 of them at once? :huh:

M23

P.S. If you still have problems I will split our discussion into another thread as I do not want to end up with another 3 pages of debugging only to find that it is a problem on your machine. ;)

Edit: I have amended the example to make this clear. :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

Melba23,

I am extreamely sorry! i don't know what is i am doing wrong for me it is not working. :( . i just added the Header file as "#include "CFF_Embed.au3"" and the line

$sRoot = GUICtrlRead($DrivePath) & ""
$sSel = _CFF_Embed($hTreeView, $sRoot, "*.*", 12)

but still nothing is prompts. really i am not sure what was wrong with my coding : could you please help me?

Here is my complete code:

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=database-next.ico
#AutoIt3Wrapper_Outfile=DCU.exe
#AutoIt3Wrapper_Res_Comment=Data Restoration Utility
#AutoIt3Wrapper_Res_Description=Data Restoration Utility
#AutoIt3Wrapper_Res_Fileversion=1.0.0.4
#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"
#include "AD.au3"
#include "CFF_Embed.au3"
Opt('TrayAutoPause', 0)
Global $DocER = 0
Global $Docsel = 0
Global $tri = 0
Global $compname = @ComputerName
Global $SR, $sFQDN
Global $Err_msg = _WinAPI_GetLastErrorMessage()
FileInstall("C:UsersQ03200Desktoptick.jpg", @DesktopDir & "tick.jpg", 1)
FileInstall("C:UsersQ03200Desktoperror.jpg", @DesktopDir & "error.jpg", 1)
FileInstall("C:UsersQ03200Desktopinfo.jpg", @DesktopDir & "info.jpg", 1)
HotKeySet("{F1}", "about")
FileInstall("C:UsersQ03200DesktopLocation.xml", @DesktopDir & "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 = @DesktopDir & "tick.jpg"
Global $ErrorFile = @DesktopDir & "error.jpg"
Global $info = @DesktopDir & "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, 330, 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 Optional Folder", 30, 285, 170, 40)
$ProfileBox = GUICtrlCreateCombo("", 160, 280, 160, 40, $CBS_DROPDOWNLIST)
GUICtrlSetState($ProfileBox, $GUI_DISABLE)

$hTreeView = _GUICtrlTreeView_Create($BaseGUI, 370, 70, 340, 300, $iStyle, $WS_EX_CLIENTEDGE)


;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)
$hMarquee1 = _GUICtrlMarquee_Create("Contact " & '"' & "Karthikeyan.Ganesan@kcc.com / 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)

_AD_Open()
Global $sFQDN = _AD_SamAccountNameToFQDN($compname & "$")
If Not @error Then
If StringInStr($sFQDN, "OU=NorthAmerica") Then
$SR = "NA"
EndIf
ElseIf @error = 1 Then
_FileWriteLog($Log, "Extended Error" & @error & ">>" & "No record returned from Active Directory")
Else
_FileWriteLog($Log, "Extended Error" & @error)
EndIf
_AD_Close()


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(@DesktopDir & "Location.xml")
FileDelete(@DesktopDir & "tick.jpg")
FileDelete(@DesktopDir & "error.jpg")
FileDelete(@DesktopDir & "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])
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 = $DrivePath Then
$sRoot = GUICtrlRead($DrivePath) & ""
$sSel = _CFF_Embed($hTreeView, $sRoot, "*.*", 12)
MsgBox(0,"",$sSel)
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)
If $SR = "NA" Then
GUICtrlSetState($hMarquee1, $GUI_SHOW)
Else
GUICtrlSetState($hMarquee, $GUI_SHOW)
EndIf

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)

_GUICtrlTreeView_BeginUpdate($hTreeView)

$aArray = _RecFileListToArray(GUICtrlRead($DrivePath) & "" & GUICtrlRead($ProfileBox))

$hItem = _GUICtrlTreeView_Add($hTreeView, 0, GUICtrlRead($DrivePath) & "" & GUICtrlRead($ProfileBox) & "")
_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(GUICtrlRead($DrivePath) & "" & GUICtrlRead($ProfileBox) & "" & $aArray[$x])
For $Y = 1 To UBound($Laray) - 1
$Do = _GUICtrlTreeView_AddChild($hTreeView, $So, $Laray[$Y])
$MArray = _RecFileListToArray(GUICtrlRead($DrivePath) & "" & GUICtrlRead($ProfileBox) & "" & $aArray[$x] & "" & $Laray[$Y])
For $P = 1 To UBound($MArray) - 1
_GUICtrlTreeView_AddChild($hTreeView, $Do, $MArray[$P])
Next

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   ;==>profilebox


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, "OK", $Title, "Microsoft Outlook is in Use. Please close Outlook and then click OK to Continue the copying process.")
_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
Else
_FileWriteLog($Log, "DRU>INFO>DOCS> My Documents is not selected  -->" & GUICtrlRead($Mydocs))
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
Else
_FileWriteLog($Log, "DRU>INFO>DESKTOP> Desktop is not selected  -->" & GUICtrlRead($DESK))
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")
Else
_FileWriteLog($Log, "DRU>INFO>FAV> Favorite is not selected  -->" & GUICtrlRead($FAV))
EndIf
If GUICtrlRead($OFF) = "1" Then
_GUICtrlRichEdit_WriteLine($iMemo, "Started copying Office folder " & @CRLF, "", "", 0xFE2EF7)
$file = _XMLFileOpen(@DesktopDir & "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
Else
_FileWriteLog($Log, "DRU>INFO>OFF> Office setting is not selected  -->" & GUICtrlRead($OFF))
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(@DesktopDir & "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. Error Value= " & @error)
EndIf
Else
_FileWriteLog($Log, "DRU>INFO>Avaya> Avaya is not selected  -->" & GUICtrlRead($AVA))
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(@DesktopDir & "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

Else
_FileWriteLog($Log, "DRU>INFO>CRYPTO> CRYPTO is not selected  -->" & GUICtrlRead($CRYPTO))
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)
Else
_FileWriteLog($Log, "DRU>INFO>PST> PST is not selected  -->" & GUICtrlRead($PSTS))
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" & StringTrimLeft($GetpathArray[$ta], 1) & "" & $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
Else
_FileWriteLog($Log, "DRU>INFO>Profile> ProfileBox is not selected  -->" & GUICtrlRead($ProfileBox))
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)
MsgBox(0,"",$hTvItem)
;-------------- 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

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to post
Share on other sites

Syed23,

Some friendly advice as Melba23 is trying to help you. Provide links to those UDFs or at least create 'executable' code as looking at code and running code are two very different things.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...