Jump to content
Sign in to follow this  
marcsusy

I need help GUICtrlCreateTreeViewItem

Recommended Posts

marcsusy

Pardon my bad English, I need help from yours. I created a program to read the structure of the C and D drive on a remote computer similar to Windows Explorer, then copy it to a location, but my problem is in getting the full path to a selected directory, I tried several variants, but so far I can not find one that is correct.

I've seen another solution in the Forum, but I would make this work I've done.

Then copy the complete program

"Please someone help me?

my code is as follows

#include <GUIConstantsEx.au3>

#include <TreeviewConstants.au3>

#include <WindowsConstants.au3>

#include <GuiTreeView.au3>

#include <GuiImageList.au3>

#include <Constants.au3>

#Include <File.au3>

;====================================

DIM $PC

Local $foo

$PC = InputBox("", "NOMBRE DE PC")

FileDelete("C:\Windows\Temp\*.txt")

;==============================================================================================================================

$foo = Run( @ComSpec & " /c Tree \\"&$PC&"\C$ /A > C:\Windows\Temp\Unidadc.txt", "" , @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD )

Local $line

ProgressOn("CREANDO LISTADO CARPETAS UNIDAD C:\", "TardarĂ¡ Algunos Segundos", "0 perciento")

While 1

$line = StdoutRead($foo)

If @error Then ExitLoop

For $i = 10 to 100 step 10

sleep(500)

ProgressSet( $i, $i & " percent")

Next

ProgressSet(100 , "Done", "CREANDO ARCHIVO TXT")

sleep(200)

Wend

ProgressOff()

;===============================================================================================================================

$foo = Run( @ComSpec & " /c Tree \\"&$PC&"\D$ /A > C:\Windows\Temp\Unidadd.txt", "" , @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD )

Local $line

ProgressOn("CREANDO LISTADO CARPETAS UNIDAD D:\", "TardarĂ¡ Algunos Segundos", "0 perciento")

While 1

$line = StdoutRead($foo)

If @error Then ExitLoop

For $i = 10 to 100 step 10

sleep(500)

ProgressSet( $i, $i & " percent")

Next

ProgressSet(100 , "Done", "CREANDO ARCHIVO TXT")

sleep(200)

Wend

ProgressOff()

;======================================================

$Unidadc = FileOpen("C:\Windows\Temp\Unidadc.txt", 0)

$Unidadd = FileOpen("C:\Windows\Temp\Unidadd.txt", 0)

;====================================================================================================================================

RunWait( @ComSpec & " /c copy c:\windows\temp\Unidadc.txt + C:\WINDOWS\Temp\Unidadd.txt C:\Windows\Temp\Explorer.txt", "", @SW_HIDE)

;====================================================================================================================================

$Explorer = FileOpen("C:\Windows\Temp\Explorer.txt", 0)

$rr = _FileCountLines("C:\Windows\Temp\Explorer.txt")

Dim $Cont, $Posicion

DIM $Pos[$rr], $Nom[$rr], $In, $Poss[$rr]

$In = 1

$Cont = 0

;=============================================================================================================================================

;AGREGADO

$gui = GUICreate("EXPLORADOR DE ARCHIVOS PC "&$PC&" ", 425, 473, 398, 125)

$treeview = GUICtrlCreateTreeView(6, 6, 416, 408, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE)

$h_tree = ControlGetHandle($gui, "", $treeview)

$Button1 = GUICtrlCreateButton("ACEPTAR", 168, 432, 75, 25, $WS_GROUP)

GUISetState(@SW_SHOW)

;=============================================================================================================================================

$hImage = _GUIImageList_Create(16, 16, 5, 3)

;=====================================================

for $a = 0 to $rr ;$Variablearreglo

_GUIImageList_AddIcon($hImage, "shell32.dll", 110)

Next

;======================================================

_GUICtrlTreeView_SetNormalImageList($TreeView, $hImage)

DIM $Conteo = 0

While 1

$Leida = FileReadLine("C:\Windows\Temp\Explorer.txt", $In)

If @error = -1 Then ExitLoop

$Pos[$Cont] = StringInStr($Leida, "C$")

IF $Pos[$Cont] > 0 Then ; 1

IF $Conteo = 0 Then

$root = GUICtrlCreateTreeViewItem("DISCO LOCAL C:\", $treeview)

$Conteo = $Conteo + 1

Endif

Else ; 1

$Pos[$Cont] = StringInStr($Leida, "D$")

IF $Pos[$Cont] > 0 Then

If FileExists("C\Windows\Temp\Conteo.txt") Then

; NO HACE NADA

Else

$root = GUICtrlCreateTreeViewItem("DISCO LOCAL D:\", $treeview)

FileOpen("C:\WINDOWS\Temp\Contar.txt", 1)

Endif

Endif

$Pos[$Cont] = StringInStr($Leida, "+")

IF $Pos[$Cont] = 0 Then ; 2

$Pos[$Cont] = StringInStr($Leida, "\")

;====================================

;AGREGADO SE PUEDE QUITAR COMPLETO

IF $Pos[$Cont] > 0 Then

$M = StringSplit($Leida, "\", 0)

IF $M[0] = 4 Then

$Pos[$Cont] = 0

Endif

Endif

;====================================

Endif ; 2

Endif; 1

Switch $Pos[$Cont]

Case 1 to 500

$Posicion = $Pos[$Cont]

$Nom[$Cont] = StringRight($Leida, StringLen($Leida) - ($Pos[$Cont] + 3))

;========================================================================

; CASE PARA SABER SI ES UN DIRECTORIO RAIZ

$Poss[0] = ""

Switch $Posicion

Case 1

$Poss[1] = GUICtrlCreateTreeViewItem($Nom[$Cont], $root)

_GUICtrlTreeView_Expand($TreeView, $Poss[1])

Case 5

$Poss[5] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[1])

Case 9

$Poss[9] = GUICtrlCreateTreeViewItem($Nom[$Cont],$Poss[5])

Case 13

$Poss[13] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[9])

Case 17

$Poss[17] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[13])

Case 21

$Poss[21] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[17])

Case 25

$Poss[25] = GUICtrlCreateTreeViewItem($Nom[$Cont],$Poss[21])

Case 29

$Poss[29] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[25])

Case 33

$Poss[33] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[29])

Case 37

$Poss[37] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[33])

Case 41

$Poss[41] = GUICtrlCreateTreeViewItem($Nom[$Cont],$Poss[37])

Case 45

$Poss[45] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[41])

Case 49

$Poss[49] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[45])

Case 53

$Poss[53] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[49])

Case 57

$Poss[57] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[53])

Case 61

$Poss[61] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[57])

Case 65

$Poss[65] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[61])

Case 69

$Poss[69] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[65])

Case 73

$Poss[73] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[69])

Case 77

$Poss[77] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[73])

Case 81

$Poss[81] = GUICtrlCreateTreeViewItem($Nom[$Cont], $Poss[77])

EndSwitch

EndSwitch

;=============================================================

$Cont = $Cont + 1

$In = $In + 1

Wend

FileClose($Unidadc)

FileClose($Unidadd)

FileClose($Explorer)

$Escrit = FileOpen("C:\Windows\Temp\prueba.txt", 1)

DIM $DI[1]

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

Dim $Texto

For $u = 1 to (ubound($Poss) - 1)

If _GUICtrlTreeView_GetChecked($treeview, $u) Then

$Padre = _GUICtrlTreeView_GetPrev($TreeView, $Pos[$u])

$POSICION = $Pos[$u]

for $uu = $u to 1 Step -1

$Padree = _GUICtrlTreeView_GetPrev($TreeView, $Pos[$uu])

IF $Padre <> $Padree and $POSICION < $Pos[$uu] Then

$Texto = _GUICtrlTreeView_GetText($TreeView, $Pos[$uu])

FileWriteLine("C:\Windows\Temp\prueba.txt", "POSICION "&$Pos[$uu]& "\"&$Texto&""& @CRLF )

$Padre = _GUICtrlTreeView_GetPrev($TreeView, $Pos[$uu])

$POSICION = $Pos[$uu]

Endif

Next

EndIf

Next

ExitLoop

EndSwitch

WEnd

FileClose($Escrit)

MsgBox(0,"", "HE CONCLUIDO")

Share this post


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
Sign in to follow this  

×