► Afficher le texte
Code : Tout sélectionner
#include <StructureConstants.au3>
#include <GuiImageList.au3>
#include <TreeViewConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <File.au3>
#include <ListviewConstants.au3>
$sPath = 'C:'
$sPathh = 'D:'
$hGui = GUICreate('Back Up Station', 402, 658, 349, 136)
$hTreeview = GUICtrlCreateTreeView(10, 26, 380, 568, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES))
$hWndTreeview = GUICtrlGetHandle($hTreeview)
$hOk = GUICtrlCreateButton('Sauvegarde', 48, 615, 76, 22)
$hCancel = GUICtrlCreateButton('Restauration', 160, 615, 76, 22)
$hAide = GUICtrlCreateButton('Aide', 272, 615, 76, 22)
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 4)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 1)
_GUICtrlTreeView_SetNormalImageList($hTreeview, $hImage)
GUISetState()
GUICtrlSetStyle($hTreeview, Default, $WS_EX_COMPOSITED + $WS_EX_CLIENTEDGE)
;~ ######################################################################################################################## integration des repertoires
$hRoot = _GUICtrlTreeView_Add($hTreeview, $hTreeview, $sPath, 0, 0)
_GUICtrlTreeView_SetChecked($hTreeview, $hRoot)
_GUICtrlTreeView_SetState($hTreeview, $hRoot, $TVIS_EXPANDED)
_GUICtrlTreeView_SetState($hTreeview, $hRoot, $TVIS_EXPANDED)
$hRoot1 = _GUICtrlTreeView_Add($hTreeview, $hTreeview, $sPathh, 0, 0)
_GUICtrlTreeView_SetChecked($hTreeview, $hRoot1)
_GUICtrlTreeView_SetState($hTreeview, $hRoot, $TVIS_EXPANDED)
;~ ######################################################################################################################## arborescence des repertoires
_GUICtrlTreeView_BeginUpdate($hTreeview)
GUISetCursor(15, 1, $hGui)
_GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hRoot, $sPath, 2)
GUISetCursor(2, 1, $hGui)
_GUICtrlTreeView_EndUpdate($hTreeview)
_GUICtrlTreeView_BeginUpdate($hTreeview)
GUISetCursor(15, 1, $hGui)
_GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hRoot, $sPathh, 2)
GUISetCursor(2, 1, $hGui)
_GUICtrlTreeView_EndUpdate($hTreeview)
GUICtrlSetState(-1, $GUI_CHECKED)
;~ ######################################################################################################################## Fonction
Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
GUIRegisterMsg($WM_NOTIFY, '')
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, 'hWndFrom'))
$iCode = DllStructGetData($tNMHDR, 'Code')
If $hWndFrom = $hWndTreeview And $iCode = $NM_CLICK Then
ToolTip('Please wait...', Default, Default, 'Read Directory', 1)
_GUICtrlTreeView_FileExplorer($hGui, $hTreeview)
ToolTip('')
EndIf
GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
Return $GUI_RUNDEFMSG
EndFunc
;~ ######################################################################################################################## Fonction
Func _GUICtrlTreeView_FileExplorer($hGui, $hTreeview)
Local $aTVPos, $aPos, $hItem, $hChild, $sTree
$aTVPos = ControlGetPos($hGui, '', $hTreeview)
$aPos = GUIGetCursorInfo($hGui)
$check= GUICtrlSetState(-1, $GUI_CHECKED)
$hItem = _GUICtrlTreeView_HitTestItem($hTreeview, $aPos[0], $aPos[1] - $aTVPos[1])
If _GUICtrlTreeView_GetExpanded($hTreeview, $hItem) Then Return
$hChild = _GUICtrlTreeView_GetFirstChild($hTreeview, $hItem)
_GUICtrlTreeView_BeginUpdate($hTreeview)
If $hChild <> 0 Then
$sTree = StringReplace(_GUICtrlTreeView_GetTree($hTreeview, $hChild), '|', '\')
_GUICtrlTreeView_DeleteChildren($hTreeview, $hChild)
_GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hChild, $sTree, 1)
EndIf
Do
$hChild = _GUICtrlTreeView_GetNextChild($hTreeview, $hChild)
If $hChild <> 0 Then
$sTree = StringReplace(_GUICtrlTreeView_GetTree($hTreeview, $hChild), '|', '\')
_GUICtrlTreeView_DeleteChildren($hTreeview, $hChild)
$iTimer = TimerInit()
_GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hChild, $sTree, 1)
EndIf
Until $hChild = 0
_GUICtrlTreeView_EndUpdate($hTreeview)
EndFunc ;==>_GUICtrlTreeView_FileExplorer
;~ ######################################################################################################################## Fonction
Func _GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hItem, $sPath, $iRec)
Local $aDirList, $aFileList, $tmp, $hIcon
$iRec -= 1
$aDirList = _FileListToArray($sPath, '*', 2)
If IsArray($aDirList) Then
For $i = 1 To $aDirList[0]
If Not StringInStr(FileGetAttrib($sPath & '\' & $aDirList[$i]), 's') Then
$tmp = _GUICtrlTreeView_AddChild($hTreeview, $hItem, $aDirList[$i], 0, 0)
_GUICtrlTreeView_SetChecked($hTreeview, $tmp)
If $iRec > 0 Then _GUICtrlTreeView_FileExplorerRecursive($hTreeview, $tmp, $sPath & '\' & $aDirList[$i], $iRec)
EndIf
Next
EndIf
$aFileList = _FileListToArray($sPath, '*', 1)
If IsArray($aFileList) Then
For $i = 1 To $aFileList[0]
If Not StringInStr(FileGetAttrib($sPath & '\' & $aFileList[$i]), 's') Then
$hIcon = _GUIImageList_AddIcon($hImage, $sPath & '\' & $aFileList[$i], 0)
If $hIcon = 0 Then
$hIcon = 1
Else
_GUICtrlTreeView_SetNormalImageList($hTreeview, $hImage)
EndIf
$tmp = _GUICtrlTreeView_AddChild($hTreeview, $hItem, $aFileList[$i], $hIcon, $hIcon)
_GUICtrlTreeView_SetChecked($hTreeview, $tmp)
EndIf
Next
EndIf
EndFunc ;==>_GUICtrlTreeView_FileExplorerRecursive
;~ ######################################################################################################################## option des boutons
GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $hCancel
Exit
Case $hOk ;################################################################################# Detection des cases non cocher
$iSelect = _GUICtrlTreeView_GetSelection($hTreeview)
$sTree = StringReplace(_GUICtrlTreeView_GetTree($hTreeview, $iSelect), '|', '\')
MsgBox(0, 'éléments non sauvegarder', $sTree)
Case $hAide
$Aide_txt = "Aide.txt"
run("notepad Aide.txt")
EndSwitch
WEndVoila un script autoit avec une arborescence.
Mon probleme est le suivant
comme vous pouvez le constater en cliquant sur le boutons "sauvegarde" cela renvoie le focus
j'aimerai que au lieu de renvoyer le focus il me renvoie les cases non cocher qu'importe leurs nombre
avec pour nom $Nocheck
Merci pour votre aide.


