loganhunter2009 Posted December 5, 2013 Posted December 5, 2013 I'm still a bit new to the GUICtrlTreeView and I have some problems. I am trying to write a script to select multiple items in the tree view of an application but it doesn't seems to be able to to. I've tried to get the handle using _GUICtrlTreeView_FindItem but it can't find the item and then I've tried _GUICtrlTreeView_GetFirstItem which returns the first item in the tree. The first question is why does _GUICtrlTreeView_GetFirstItem not work? The application is 64-bit so is it not compatible? My second question is that using _GUICtrlTreeView_SetSelected to multiselect items in the tree doesn't work. However, when I use _GUICtrlTreeView_SelectItem, it works but only selects one item. I've included my code below. Thanks in advance. expandcollapse popup#include <GUIConstantsEx.au3> #include <GUITreeView.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> Opt("GUIDataSeparatorChar", "\") Global $hWnd = ControlGetHandle("[CLASS:ORALTClass; TITLE:LightTools]", "", "[CLASS:SysTreeView32; INSTANCE:3]") $GetHandleCount = ControlTreeView("[CLASS:ORALTClass; TITLE:LightTools]", "", $hWnd, "GetItemCount") ; Returns Window Handle is 0x00AC0018 ConsoleWrite ("Window Handle is " & $hWnd & @CRLF) ; Returns Number of item in tree is 9 ConsoleWrite ("Number of item in tree is " & $GetHandleCount & @CRLF) $hSelected_Item = _GUICtrlTreeView_GetSelection($hWnd) $hTest = _GUICtrlTreeView_FindItem($hWnd, "Cube_7") ; Returns Not Found if $hTest Then ConsoleWrite("Found hTest at " & $hTest & @CRLF) Else ConsoleWrite("Not Found" & @CRLF) EndIf ; Go to Components list $hItem = _GUICtrlTreeView_GetFirstItem($hWnd) ; Get the first item under the Components Tree $hChild = _GUICtrlTreeView_GetFirstChild($hWnd, $hItem) ; Get the next item under the Components Tree $hNextChild = _GUICtrlTreeView_GetNextChild($hWnd, $hChild) $hNextChildCount = _GUICtrlTreeView_GetChildCount($hWnd, $hNextChild) $hNext2Child = _GUICtrlTreeView_GetNextSibling($hWnd,$hChild) $ExpandTest = _GUICtrlTreeView_Expand($hWnd, $hChild) ; Returns Item Handle 1 is 0x468FC400 ConsoleWrite ("Item Handle 1 is " & $hItem & @CRLF) ; Returns Child Handle 1 is 0x468B01A0 ConsoleWrite ("Child Handle 1 is " & $hChild & @CRLF) ; Returns Child Count is 2 ConsoleWrite ("Child Count is " & $hNextChildCount & @CRLF) _GUICtrlTreeView_SetSelected($hWnd, $hChild) _GUICtrlTreeView_SetSelected($hWnd, $hNextChild) ; This works _GUICtrlTreeView_SelectItem($hWnd, $hChild) ; Returns hChild State = 0 ConsoleWrite ("hChild State = " & _GUICtrlTreeView_GetState($hWnd, $hChild) & @CRLF) ; Returns hNextChild State = 0 ConsoleWrite ("hNextChild State = " & _GUICtrlTreeView_GetState($hWnd, $hNextChild) & @CRLF)
spudw2k Posted December 10, 2013 Posted December 10, 2013 I'm not so sure TreeView's support multiple select. Does the treeview you are using utilize checkboxes? Perhaps a loop through the treeview and collecting the results from _GetChecked is what you are looking for? As far as I know _GetSelection (at least according to the help file), "Retrieves the currently selected item". 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
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