DenisB Posted July 31, 2019 Share Posted July 31, 2019 I've tried writing my own code to access items in ControlTreeView with zero success. For the sake of my education example code that navigates the SysTreeView32 in the File explorer and "right clicks" the "Documents" entry would be really helpful. I can't event get ControlTreeView "Get Text" to work so I don't know how I could "step through" the items to find "Documents". I'd very much appreciate a working example. In Windows10Pro File Explorer opens with the bottom left pane being [Class:SysTreeView32;INSTANCE;1] here is my code #include <GUIConstantsEx.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #AutoIt3Wrapper_UseX64 run ("explorer") sleep(100) WinActivate("File Explorer") sleep (100) local $ctrHndl = ControlGetHandle("File Explorer","","[Class:SysTreeView32;INSTANCE:1]") MSGBOX(0,"","Display Control Handle $ctrHndl : " & $ctrHndl) msgbox displays 0x00000000 $Result1 = ControlTreeView("File Explorer","","[Class:SysTreeView32;INSTANCE:1]","GetItemCount") MSGBOX(0,"","Display ControlTreeView Count : " & $Result1) mgsbox displays "2" $Result1 = ControlTreeView("File Explorer","","[Class:SysTreeView32;INSTANCE:1]","GetText",1) MSGBOX(0,"","Display ControlTreeView Text : " & $Result1) msgbox displays "" Link to comment Share on other sites More sharing options...
alienclone Posted August 1, 2019 Share Posted August 1, 2019 i dont think the file explorer window is actually named 'File Explorer', it should be named whatever it is open to... for instance, my file explorer opens to This PC If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
Nine Posted August 1, 2019 Share Posted August 1, 2019 #include <GuiTreeView.au3> #AutoIt3Wrapper_UseX64 Run ("explorer") Sleep(500) Local $hWnd = WinActivate("[CLASS:CabinetWClass]") MsgBox ($MB_SYSTEMMODAL,"",$hWnd) Local $ctrHndl = ControlGetHandle($hWnd,"","[Class:SysTreeView32;INSTANCE:1]") MsgBox ($MB_SYSTEMMODAL,"","Display Control Handle $ctrHndl : " & $ctrHndl) Local $Result1 = _GUICtrlTreeView_GetCount($ctrHndl) MsgBox ($MB_SYSTEMMODAL,"","Display ControlTreeView Count : " & $Result1) I got this so far...But I am not sure it is possible to go way further. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
spudw2k Posted August 1, 2019 Share Posted August 1, 2019 What is the end goal? There may be an easier way to reach it rather than manipulating UI controls; not to say that is a bad way to go or discourage the approach necessarily, but if the end goal can be reached by other means and with fewer commands (versus simulating clicks and key presses) that should be worth considering. Having said that, here's more to chew on: #include <GuiTreeView.au3> #AutoIt3Wrapper_UseX64 Run ("explorer") Sleep(500) Local $hWnd = WinActivate("[CLASS:CabinetWClass]") ;MsgBox ($MB_SYSTEMMODAL,"",$hWnd) Local $ctrHndl = ControlGetHandle($hWnd,"","[Class:SysTreeView32;INSTANCE:1]") ;MsgBox ($MB_SYSTEMMODAL,"","Display Control Handle $ctrHndl : " & $ctrHndl) Local $Result1 = _GUICtrlTreeView_GetCount($ctrHndl) ;MsgBox ($MB_SYSTEMMODAL,"","Display ControlTreeView Count : " & $Result1) $iItem = _GUICtrlTreeView_GetFirstItem($ctrHndl) While $iItem $hItem = _GUICtrlTreeView_GetItemHandle($iItem, $iItem) $sItem = _GUICtrlTreeView_GetText($ctrHndl, $hItem) ConsoleWrite($hItem & @TAB & $sItem & @CRLF) $iChild = _GUICtrlTreeView_GetChildCount($ctrHndl, $iItem) If $iChild <> -1 Then $iItem = _GUICtrlTreeView_GetFirstChild($ctrHndl, $iItem) Else $iItem = _GUICtrlTreeView_GetNext($ctrHndl, $iItem) EndIf WEnd Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
DenisB Posted August 1, 2019 Author Share Posted August 1, 2019 11 hours ago, spudw2k said: What is the end goal? There may be an easier way to reach it rather than manipulating UI controls; not to say that is a bad way to go or discourage the approach necessarily, but if the end goal can be reached by other means and with fewer commands (versus simulating clicks and key presses) that should be worth considering. Having said that, here's more to chew on: #include <GuiTreeView.au3> #AutoIt3Wrapper_UseX64 Run ("explorer") Sleep(500) Local $hWnd = WinActivate("[CLASS:CabinetWClass]") ;MsgBox ($MB_SYSTEMMODAL,"",$hWnd) Local $ctrHndl = ControlGetHandle($hWnd,"","[Class:SysTreeView32;INSTANCE:1]") ;MsgBox ($MB_SYSTEMMODAL,"","Display Control Handle $ctrHndl : " & $ctrHndl) Local $Result1 = _GUICtrlTreeView_GetCount($ctrHndl) ;MsgBox ($MB_SYSTEMMODAL,"","Display ControlTreeView Count : " & $Result1) $iItem = _GUICtrlTreeView_GetFirstItem($ctrHndl) While $iItem $hItem = _GUICtrlTreeView_GetItemHandle($iItem, $iItem) $sItem = _GUICtrlTreeView_GetText($ctrHndl, $hItem) ConsoleWrite($hItem & @TAB & $sItem & @CRLF) $iChild = _GUICtrlTreeView_GetChildCount($ctrHndl, $iItem) If $iChild <> -1 Then $iItem = _GUICtrlTreeView_GetFirstChild($ctrHndl, $iItem) Else $iItem = _GUICtrlTreeView_GetNext($ctrHndl, $iItem) EndIf WEnd I need to write a script to do a "soak test" to repeatedly download a process automation controller. The software used to initiate this download lists the controllers in a system tree. I need to select a specific controller, "right click it" and then select a specific type of download from the options presented when the right-click is made. Instead of asking my question in the context of a specific application that fewer people would be aware of, I chose File Explorer to request as an example of how to actually use ControlTreeView. One of the criteria of this soak test is that I mimic the user's keystrokes as accurately as possible. 1000 thanks. I am grateful to all of you! Link to comment Share on other sites More sharing options...
DenisB Posted August 6, 2019 Author Share Posted August 6, 2019 I think _GUICtrlTreeView_GetText and _GUICtrlTreeView_GetSelected only work on SystemTrees created by AutoIt. I can't get them to work with the windows file explorer. Link to comment Share on other sites More sharing options...
Nine Posted August 6, 2019 Share Posted August 6, 2019 Agree, same here. Win7 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
spudw2k Posted August 6, 2019 Share Posted August 6, 2019 (edited) @DenisB I disagree. I used _GetText in the example I made above that you quoted, and _GetSelected works for me in this demo: #include <GuiTreeView.au3> #include <Array.au3> #AutoIt3Wrapper_UseX64 Run ("explorer") Sleep(500) Local $hWnd = WinActivate("[CLASS:CabinetWClass]") Local $hTreeView = ControlGetHandle($hWnd,"","[Class:SysTreeView32;INSTANCE:1]") Local $iTreeViewItemCount = _GUICtrlTreeView_GetCount($hTreeView) Local $aTreeViewContents[1][3]=[["Item_Handle","Item_Text","Item_Selected"]] ReDim $aTreeViewContents[$iTreeViewItemCount+1][3] $iIdx = 1 $hItem = _GUICtrlTreeView_GetFirstItem($hTreeView) While $hItem $aTreeViewContents[$iIdx][0] = $hItem $aTreeViewContents[$iIdx][1] = _GUICtrlTreeView_GetText($hTreeView, $hItem) $aTreeViewContents[$iIdx][2] = _GUICtrlTreeView_GetSelected($hTreeView, $hItem) $iChild = _GUICtrlTreeView_GetChildCount($hTreeView, $hItem) If $iChild <> -1 Then $hItem = _GUICtrlTreeView_GetFirstChild($hTreeView, $hItem) Else $hItem = _GUICtrlTreeView_GetNext($hTreeView, $hItem) EndIf $iIdx += 1 WEnd _ArrayDisplay($aTreeViewContents) MsgBox(0,"Currently Selected TreeView Item",_GUICtrlTreeView_GetText($hTreeView,_GUICtrlTreeView_GetSelection($hTreeView))) @Nine Sorry, I'm a little confused. You wrote the example above that I built on, so I assume my example would have worked for you as well. The examples I made work for me on Win 10 1809. Edited August 7, 2019 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Nine Posted August 7, 2019 Share Posted August 7, 2019 No need to be sorry. It was Just a simple observation. That's why I was "not sure it is possible to go way further". Maybe it will work on w10, I didn't invest time to find out. But I must agree with you that going by that road is not the approach I would use... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
DenisB Posted August 7, 2019 Author Share Posted August 7, 2019 Thank you spudw2k. I've got no ego investment here and evidently I'm deficient. I'm on Windows10 Pro and I'll dig back into this later today. If I'm still stuck I'll give much more information for you all to help me (if you haven't come to the realization that I'm beyond help by then.) Again 1000 thanks for your help and patience. Link to comment Share on other sites More sharing options...
spudw2k Posted August 8, 2019 Share Posted August 8, 2019 Certainly. I'm not being judgmental or anything (at least that is not my intent), just pointing out that it should be capable of working. If it isn't, there is something else going on that hopefully can be resolved. Let us know when/where you get stuck. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
DenisB Posted August 8, 2019 Author Share Posted August 8, 2019 (edited) Here is a screen cap of what I get when I run the code posted by spudw2k 20190806_18:25. I tried to redact 3 nodes in the tree since this is my work computer. Here is a screen cap of what I get when I run the code posted Edited August 8, 2019 by DenisB Link to comment Share on other sites More sharing options...
spudw2k Posted August 8, 2019 Share Posted August 8, 2019 (edited) interesting. Attached is a screenshot of it on my PC. I notice your item handles look like they are 32-bit compared to mine. Are you sure you are running the x64 AutoIt Interpreter? Perhaps correcting the Usex64 wrapper as follows will help: #AutoIt3Wrapper_UseX64=y. I corrected it above. I suspect without the =y it is being omitted. The default interpreter on my machine is x64, whereas it is x32 on yours...my hunch. Edited August 8, 2019 by spudw2k Nine 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Nine Posted August 8, 2019 Share Posted August 8, 2019 Now working, even on win 7, congrats spud “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
DenisB Posted August 9, 2019 Author Share Posted August 9, 2019 adding "=y" fixed my problem! 1000 more thanks spudw2k Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now