NBenitus Posted June 25, 2009 Share Posted June 25, 2009 Hi all,Here is the situation. I have the following tree view:Parent (Only one parent with name "Server")- Children 1- Children 2- Children 3My goal is to go to through each children and get the text.I read the page http://www.autoitscript.com/autoit3/docs/f...rolTreeView.htm, but I still can't figure out how to do it as I don't know how to reach the children nor get the children text, even after many attempts.Any help would be greatly appreciated.Sincerely,B. Link to comment Share on other sites More sharing options...
bo8ster Posted June 25, 2009 Share Posted June 25, 2009 I would suggest the following. You can work out the syntax Get Handle to the Control (ControlGetHandle) and then test to make sure you have it - call it $hwd $aChildNames For $i = 0 to ControlTreeView($hwd, , , "GetItemCount") _ArrayAdd($aChildNames, ControlTreeView($hwd, , , "GetText", $i)) Next _ArrayDisplay($aChildNames) You might want to put some error checking in or ConsoleWrite the return string of ControlTreeView($hwd, , , "GetText", $i) to see if you are on the right track. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
NBenitus Posted June 25, 2009 Author Share Posted June 25, 2009 I would suggest the following.You can work out the syntaxGet Handle to the Control (ControlGetHandle) and then test to make sure you have it - call it $hwd$aChildNames For $i = 0 to ControlTreeView($hwd, , , "GetItemCount") _ArrayAdd($aChildNames, ControlTreeView($hwd, , , "GetText", $i))Next_ArrayDisplay($aChildNames)You might want to put some error checking in or ConsoleWrite the return string of ControlTreeView($hwd, , , "GetText", $i) to see if you are on the right track.Thanks a lot, I will try that . Link to comment Share on other sites More sharing options...
NBenitus Posted June 25, 2009 Author Share Posted June 25, 2009 I am unsure how to test if I got the handle correctly or not. Here's the modified code with your suggestions: $hwd = ControlGetHandle("server2", "", "[CLASS:WindowsForms10.SysTreeView32.app.0.259f9d2; INSTANCE:1]") For $i = 0 to ControlTreeView("server2", "", $hwd, "GetItemCount") ConsoleWrite(ControlTreeView("server2", "", $hwd, "GetText", $i)) Next Unfortunately, it is still not working . Link to comment Share on other sites More sharing options...
NBenitus Posted June 25, 2009 Author Share Posted June 25, 2009 (edited) After investigation, the method "GetItemCount" always return me "1" even if I have four children. Am I missing something? Edited June 25, 2009 by NBenitus Link to comment Share on other sites More sharing options...
bo8ster Posted June 26, 2009 Share Posted June 26, 2009 You really want to make sure you get the handle (and the correct one). I would do ConsoleWrite("The Handle is " & $hwd) (or u can use a msgbox) just after the ControlGetHandle command. Then compare this to the handle shown in the (Summary Tab) Control Section of the Info Tool. There will be two handles, one for the window and one for the control. Can you copy the out put of the Info Tool. Reading the help file more closely, ConsoleWrite(ControlTreeView("server2", "", $hwd, "GetText", $i)) will not work. You have to use "Root|Item 1" or something for the item to get the child count. Firstly make sure you get the handle then try to get the count of the sub items. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
NBenitus Posted June 26, 2009 Author Share Posted June 26, 2009 You really want to make sure you get the handle (and the correct one). I would do ConsoleWrite("The Handle is " & $hwd) (or u can use a msgbox) just after the ControlGetHandle command. Then compare this to the handle shown in the (Summary Tab) Control Section of the Info Tool. There will be two handles, one for the window and one for the control. Can you copy the out put of the Info Tool. Reading the help file more closely, ConsoleWrite(ControlTreeView("server2", "", $hwd, "GetText", $i)) will not work. You have to use "Root|Item 1" or something for the item to get the child count. Firstly make sure you get the handle then try to get the count of the sub items. Thanks for your help. It seems I have the correct handle, it matches the handle listed in the Control section of the Window Info window. The following line still displays 1 children: $hwd = ControlGetHandle("server2 - VMware Infrastructure Client", "", "[CLASS:WindowsForms10.SysTreeView32.app.0.259f9d2; INSTANCE:1]") ConsoleWrite("The number of children is " & ControlTreeView("server2", "", $hwd, "GetItemCount")) For the output: >>>> Control <<<< Class: WindowsForms10.SysTreeView32.app.0.259f9d2 Instance: 1 ClassnameNN: WindowsForms10.SysTreeView32.app.0.259f9d21 Advanced (Class): [CLASS:WindowsForms10.SysTreeView32.app.0.259f9d2; INSTANCE:1] ID: 9507150 Text: Position: 2, 91 Size: 196, 211 ControlClick Coords: 90, 70 Style: 0x5601002D ExStyle: 0x00000000 Handle: 0x0091114E Note: The ID and Handle keeps changing when I open the application. Thanks again . Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 26, 2009 Share Posted June 26, 2009 (edited) Thanks for your help. It seems I have the correct handle, it matches the handle listed in the Control section of the Window Info window. The following line still displays 1 children: $hwd = ControlGetHandle("server2 - VMware Infrastructure Client", "", "[CLASS:WindowsForms10.SysTreeView32.app.0.259f9d2; INSTANCE:1]") ConsoleWrite("The number of children is " & ControlTreeView("server2", "", $hwd, "GetItemCount")) <snip> Note: The ID and Handle keeps changing when I open the application. Thanks again . Try this: #Include <GuiTreeView.au3> $hWin = WinGetHandle("server2 - VMware Infrastructure Client", "") $sTVClass = "[CLASS:WindowsForms10.SysTreeView32.app.0.259f9d2; INSTANCE:1]" $hTV = ControlGetHandle($hWin, "", $sTVClass) $iTVCnt = _GUICtrlTreeView_GetCount($hTV) ConsoleWrite("The number of children is " & $iTVCnt) Edited June 26, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
NBenitus Posted June 26, 2009 Author Share Posted June 26, 2009 (edited) Try this: #Include <GuiTreeView.au3> $hWin = WinGetHandle("server2 - VMware Infrastructure Client", "") $sTVClass = "[CLASS:WindowsForms10.SysTreeView32.app.0.259f9d2; INSTANCE:1]" $hTV = ControlGetHandle($hWin, "", $sTVClass) $iTVCnt = _GUICtrlTreeView_GetCount($hTV) ConsoleWrite("The number of children is " & $iTVCnt) There is some progress, now it returns me 2 children, but I still have four ... Stupid tree view ... But thanks for the help PsaltyDS ! Edited June 26, 2009 by NBenitus Link to comment Share on other sites More sharing options...
bo8ster Posted June 26, 2009 Share Posted June 26, 2009 The ID and Handle changes each time because they are dynamic, thats why you have to use other properties of control that are static. I don't know GuiTreeView.au3 so I can't help there but PsaltyDS knows just about everything! Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 26, 2009 Share Posted June 26, 2009 There is some progress, now it returns me 2 children, but I still have four ... Stupid tree view ... But thanks for the help PsaltyDS ! Does this look like your treeview? And if not, what's different? #include <GuiConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> Global $hItem, $hTreeView, $hTVParent Global $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, _ $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) GUICreate("TreeView Get Count", 400, 300) $hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState() $hTVParent = _GUICtrlTreeView_Add($hTreeView, 0, "Server") For $x = 1 To 3 _GUICtrlTreeView_AddChild($hTreeView, $hTVParent, "Children " & $x) Next _GUICtrlTreeView_Expand($hTreeView, $hTVParent, True) ConsoleWrite("Count: " & _GUICtrlTreeView_GetCount($hTreeView) & @LF) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
NBenitus Posted June 26, 2009 Author Share Posted June 26, 2009 (edited) Yes, that looks like my tree view. I tried the GetSelected method and it always return me 0. Maybe it's a list view in a tree view? Edited June 26, 2009 by NBenitus Link to comment Share on other sites More sharing options...
bo8ster Posted June 29, 2009 Share Posted June 29, 2009 I would think it is by the class name but post a screen shot of the control anyway. PsaltyDS, is there a way to get more control info? Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 22, 2012 Moderators Share Posted March 22, 2012 dsk,Welcome to the AutoIt forum. To reply in a thread you use the "Reply to this topic" button at the top or the "Reply to this topic" editor at the bottom. The "Report" button you pressed is only for alerting the Mods to a problem - that is why your post has not appeared. You will also notice that this this thread is nearly 3 years old. We discourage "necro-posting" as the language has evolved a lot over the past few years and it is quite likely that there is a better way of doing things than was the case in the past. It is best to open a new thread rather then reopen one from a few years back. Look forward to seeing your new thread soon. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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