J’essaie de faire une arborescence de réseau de façon automatique, j'y suis arrivé en détournant la fonctionnalité d'une treeview
voir ce code
► Afficher le texte
Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
Global $avant_plan = 0
Global $syno_nbr_branche = 0
Dim $branche[500]
Dim $syno_handle_branche[2][1000]
$memo = 1000
$fichiermenu = @ScriptDir & "\synoptique reseau.txt"
GUICreate("Synoptique simplifié du réseau", 800, 600)
GUISetState(@SW_SHOW)
$syno_edit = GUICtrlCreateEdit("", 450, 6, 340, 400)
$but_syno_editer = GUICtrlCreateButton("Editer le fichier synoptique", 480, 450, 216, 25)
$treeview_syno = GUICtrlCreateTreeView(6, 6, 440, 590, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
_synotique_affiche($fichiermenu)
While 1
$iMsg = GUIGetMsg()
If $iMsg = $GUI_EVENT_CLOSE Then
ExitLoop
EndIf
If $iMsg = $but_syno_editer Then
RunWait("notepad.exe " & $fichiermenu)
Sleep(100)
_GUICtrlTreeView_DeleteAll($treeview_syno)
$syno_nbr_branche = 0
Sleep(100)
_synotique_affiche($fichiermenu)
EndIf
For $i = 1 To $syno_nbr_branche
If _GUICtrlTreeView_GetSelected($treeview_syno, $syno_handle_branche[0][$i]) Then
If $i <> $memo Then
$memo = $i
;~ MsgBox(0, "nbr element" & $syno_handle_branche[0][$i], $syno_handle_branche[1][$i])
$syno_coment = StringSplit($syno_handle_branche[1][$i], "#")
If IsArray($syno_coment) Then
$syno_coment_cr = ""
For $j = 1 To $syno_coment[0]
$syno_coment_cr = $syno_coment_cr & $syno_coment[$j] & @CRLF
Next
GUICtrlSetData($syno_edit, $syno_coment_cr)
Else
GUICtrlSetData($syno_edit, $syno_handle_branche[1][$i])
EndIf
EndIf
EndIf
Next
WEnd
GUIDelete()
Func _synotique_affiche($fichiermenu) ; fonction pour la création du menu
$numero_de_branche = 0
$file = FileOpen($fichiermenu, 0)
If $file = -1 Then
MsgBox($avant_plan + 4096, "", "Il manque le fichier " & $fichiermenu, 50)
FileClose($file)
Return
Else
While 1
$ligne = FileReadLine($file) ;lecture séquenciel du fichier
If @error = -1 Then ExitLoop
If StringLeft($ligne, 3) = "fin" Then ExitLoop ; arret de la boucle avec le mot fin
If StringLeft($ligne, 1) <> ";" Then
If StringInStr($ligne, "=", 0, 2) Then ;si la ligne contient 2 signes = ont poursuit le code sinon ligne suivante
$element = StringSplit($ligne, "=") ;decoupage de ligne en trois morceaux (séparés par =)
;~
If StringRight($element[1], 3) = "imp" Or StringRight($element[1], 3) = "nas" Or StringRight($element[1], 3) = "srv" Or StringRight($element[1], 3) = "pos" Or _
StringRight($element[1], 3) = "swi" Or StringRight($element[1], 3) = "rou" Or StringRight($element[1], 3) = "int" Or StringRight($element[1], 3) = "bor" Or _
StringRight($element[1], 3) = "mod" Or StringRight($element[1], 3) = "vpn" Or StringRight($element[1], 3) = "lib" Then
$numero_de_branche = StringLen(StringTrimRight($element[1], 3));comptage du nombre de caratére ( tabulation, espace) devant
If $numero_de_branche = 0 Then ;si c'est la 1er branche (0 lu dans le 3 emm morceau ) creation du menu
$branche[0] = GUICtrlCreateTreeViewItem($element[2], $treeview_syno) ;création du menu ( avec le nom stocké dans le 2 emm morceau) et stockage du handle dans le tableau $branche [1]
$syno_nbr_branche = $syno_nbr_branche + 1
$syno_handle_branche[0][$syno_nbr_branche] = $branche[0]
$syno_handle_branche[1][$syno_nbr_branche] = $element[3]
If StringRight($element[1], 3) = "imp" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[0], "shell32.dll", 60)
If StringRight($element[1], 3) = "nas" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[0], "shell32.dll", 9)
If StringRight($element[1], 3) = "srv" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[0], "shell32.dll", 186)
If StringRight($element[1], 3) = "pos" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[0], "shell32.dll", 15)
If StringRight($element[1], 3) = "swi" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[0], "shell32.dll", 121)
If StringRight($element[1], 3) = "rou" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[0], "shell32.dll", 159)
If StringRight($element[1], 3) = "int" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[0], "shell32.dll", 13)
If StringRight($element[1], 3) = "mod" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[0], "shell32.dll", 105)
If StringRight($element[1], 3) = "vpn" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[0], "shell32.dll", 164)
If StringRight($element[1], 3) = "lib" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[0], "shell32.dll", 50)
If StringRight($element[1], 3) = "bor" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[0], "shell32.dll", 243)
Else ;si la branche > de 0
$branche[$numero_de_branche] = GUICtrlCreateTreeViewItem($element[2], $branche[$numero_de_branche - 1])
$syno_nbr_branche = $syno_nbr_branche + 1
$syno_handle_branche[0][$syno_nbr_branche] = $branche[$numero_de_branche]
$syno_handle_branche[1][$syno_nbr_branche] = $element[3]
If StringRight($element[1], 3) = "imp" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[$numero_de_branche], "shell32.dll", 60)
If StringRight($element[1], 3) = "nas" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[$numero_de_branche], "shell32.dll", 9)
If StringRight($element[1], 3) = "srv" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[$numero_de_branche], "shell32.dll", 186)
If StringRight($element[1], 3) = "pos" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[$numero_de_branche], "shell32.dll", 15)
If StringRight($element[1], 3) = "swi" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[$numero_de_branche], "shell32.dll", 121)
If StringRight($element[1], 3) = "rou" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[$numero_de_branche], "shell32.dll", 159)
If StringRight($element[1], 3) = "int" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[$numero_de_branche], "shell32.dll", 13)
If StringRight($element[1], 3) = "mod" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[$numero_de_branche], "shell32.dll", 105)
If StringRight($element[1], 3) = "vpn" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[$numero_de_branche], "shell32.dll", 164)
If StringRight($element[1], 3) = "lib" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[$numero_de_branche], "shell32.dll", 50)
If StringRight($element[1], 3) = "bor" Then _GUICtrlTreeView_SetIcon($treeview_syno, $branche[$numero_de_branche], "shell32.dll", 243)
EndIf
EndIf
Else
If $syno_nbr_branche > 0 Then
$syno_handle_branche[1][$syno_nbr_branche] = $syno_handle_branche[1][$syno_nbr_branche] & "#" & StringReplace($ligne, " ", "")
EndIf
EndIf
EndIf
WEnd
_GUICtrlTreeView_Expand($treeview_syno)
FileClose($file)
EndIf
FileClose($file)
EndFunc ;==>_synotique_afficheLe résultat est pas trop mal mais j'ai quand même 3 questions
1- Selon la version de windows certain icône sont différents. j'ai téléchargé des icones plus representatif et plus morderne en .png mais j'ai pas réussi a les utiliser. est ce possible et si oui pouvez, svp , me donner la syntaxe ou la manip
2- y a t'il une possibilité d'imprimer cette treeview , autre que la copie d'écran ?
3- Connaissez vous un logiciel de dessin ou autre ou l'on pourrait envoyer, via autoit, en paramètre les informations ( branche, sous branche, icone, commentaire etc ...) pour qui génère automatiquement cette arborescence.
Merci de vos sugestions
A+ JL56



