Jump to content

How do I select a specific path in SysTreeView32


Recommended Posts

;Hi there I am trying to to search a specific path 

c:\Documents and settings\rogers\Local Settings

;the code below work but can someone point how to define the path directly, instead of searching the folder then click to select and so on
                                          
; this code below work, it finds each folder click until Local settings

                  $hWnd5 = WinGetHandle($Title,"")

                    Sleep(300)
                $hlist = ControlGetHandle($hWnd5, "", "SysListView322")
                $listid = _GUICtrlListView_FindText($hlist,"Documents and Settings" )
                _GUICtrlListView_ClickItem($hlist, $listid, "left", False, 2)
Sleep(100)
   $hlist = ControlGetHandle($hWnd5, "", "SysListView322")
                $listid = _GUICtrlListView_FindText($hlist,"rogers" )
                _GUICtrlListView_ClickItem($hlist, $listid, "left", False, 2)

Sleep(100)
$hlist = ControlGetHandle($hWnd5, "", "SysListView322")
$listid = _GUICtrlListView_FindText($hlist,"Local Settings" )
_GUICtrlListView_ClickItem($hlist, $listid, "left", False, 1)


****************************************************************************************************************************************************************
;This code below does Not work some ideas

                                                               ;$spath = "C:\"
                                                                ;$sgettext = ControlTreeView($Title,"","SysTreeView322", "select", $spath)
                                                                ;$spath = "C:\ | Documents and Settings"
                                                                ;$sgettext = ControlTreeView($Title,"","SysTreeView322", "select", $spath)
                                                                ;$spath = "Documents and Settings | rogers"
                                                                ;$sgettext = ControlTreeView($Title,"","SysTreeView322", "select", $spath)
                                                                 ;$spath = "Documents and Settings | rogers| Local Settings"
                                                                ;$sgettext = ControlTreeView($Title,"","SysTreeView322", "select", $spath)
                                                                  ;ConsoleWrite($spath &@CRLF)


                                                                 ;$Selectall = ControlListView($hWnd5, "", "SysListView322", $sgettext)
                                                                ;$Finditem = ControlListView($hWnd5, "", "SysListView322", "Finditem", "Local Settings")
                                                                ;$Select = ControlListView($hWnd5, "", "SysListView322", "Select",$Finditem)
                                                                ; consolewrite($Select)

                                                            

 

 

 

syslistview32.GIF

Link to comment
Share on other sites

I have this code working can someone point me how to delete folder "Test2



include <RecFileListToArray.au3>
#include <WinAPIFiles.au3>

$Ssearch = _RecFileListToArray("c:\Test1\","*.*", 0, 1)

For $i = 1 To UBound($Ssearch) - 1
    ConsoleWrite($Ssearch[$i] & @CRLF)
    FileDelete($Ssearch[$i])
    ;ConsoleWrite("FileDelete(" & $Ssearch[$i] & ")" & @CRLF)

Next


here is the result in console I want to delete everthing after Test1

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
Test2\
Test2\KeyFinderInstaller.exe
Test2\results.xml

 

Link to comment
Share on other sites

Not deleting I tried , I am trying to delete Test2 folder with everyting inside

#include <RecFileListToArray.au3>
#include <WinAPIFiles.au3>

$Ssearch = _RecFileListToArray("c:\Test1\","*.*", 0, 1)
Local $deleteDR = $Ssearch
For $i = 1 To UBound($Ssearch) - 1

    ;FileDelete($Ssearch[$i])
    ;ConsoleWrite("FileDelete(" & $Ssearch[$i] & ")" & @CRLF)
DirRemove($Ssearch[$i],1)
ConsoleWrite($Ssearch[$i] & @CRLF)
Next

DirRemove($deleteDR,1)
****************************************************
console

Test2\
Test2\KeyFinderInstaller.exe
Test2\results.xml

 

Link to comment
Share on other sites

I found this code orginally from SlimShady and I modify it, works like a charm. Hope it can helps someone.

include<File.au3>

local $folder1 = "C:\Test1\Test2\" ; this will delete anything after Test2, including folder directory and so on..

_DirRemoveContents($folder1, "*.*")

Func _DirRemoveContents($folder,$f)
    Local $list_of_contents, $status
    $list_of_contents = _FileListToArray($folder)
    If IsArray($list_of_contents) Then
        If StringRight($folder, 1) <> "\"  Then $folder = $folder & "\"
        If @error = 1 Then Return 1 ; No Files\Folders Found
        For $a = 1 To $list_of_contents[0]
            FileSetAttrib($folder & "\" & $list_of_contents[$a], "-RASH")
            If StringInStr(FileGetAttrib($folder & $list_of_contents[$a]), "D") Then
                $status = DirRemove($folder & $list_of_contents[$a], 1)
            Else
                $status = FileDelete($folder & $list_of_contents[$a])
            EndIf
        Next
    Else
        Return 2 ; Directory doesn't exists
    EndIf
EndFunc   ;==>_DirRemoveContents

 

Link to comment
Share on other sites

I found this code orginally from SlimShady and I modify it, works like a charm. Hope it can helps someone.

include<File.au3>

local $folder1 = "C:\Test1\Test2\" ; this will delete anything after Test2, including folder directory and so on..

_DirRemoveContents($folder1)

Func _DirRemoveContents($folder)
    Local $list_of_contents, $status
    $list_of_contents = _FileListToArray($folder)
    If IsArray($list_of_contents) Then
        If StringRight($folder, 1) <> "\"  Then $folder = $folder & "\"
        If @error = 1 Then Return 1 ; No Files\Folders Found
        For $a = 1 To $list_of_contents[0]
            FileSetAttrib($folder & "\" & $list_of_contents[$a], "-RASH")
            If StringInStr(FileGetAttrib($folder & $list_of_contents[$a]), "D") Then
                $status = DirRemove($folder & $list_of_contents[$a], 1)
            Else
                $status = FileDelete($folder & $list_of_contents[$a])
            EndIf
        Next
    Else
        Return 2 ; Directory doesn't exists
    EndIf
EndFunc   ;==>_DirRemoveContents

 

Link to comment
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
 Share

×
×
  • Create New...