zjsong Posted August 11, 2014 Share Posted August 11, 2014 I have a software, that TreeView on left side and ListView on right. Once select different items on TreeView then ListView will change, also its handle change. The problem is I can't get the handle of changed ListView and its items, I can get the first one only. how to do in this case? Thanks for your help #include <GuiTreeView.au3> $w="[CLASS:TdxW_MainFrame_Class]" $id_TreeView="[id:59650]" $id_listView="[id:100]" WinActivate ($w) WinWait($w, "", 5) $h_TreeView = ControlGetHandle($w, "",$id_TreeView ) ;select TreeView item AA ControlTreeView($w, "", $id_TreeView, "Select", "AA") $h_treeItem=_GUICtrlTreeView_GetSelection($h_TreeView ) _GUICtrlTreeView_ClickItem($h_TreeView , $h_treeItem, "left", False, 1) $h_listview_1=ControlGetHandle($w, "",$id_listView );get correct listvieew handle $itemtext_1=ControlListView ($w, "", $id_listView, "GetText" ,0,0);get correct text ;select TreeView item BB ControlTreeView($w, "", $id_TreeView, "Select", "BB") $h_treeItem=_GUICtrlTreeView_GetSelection($h_TreeView ) _GUICtrlTreeView_ClickItem($h_TreeView , $h_treeItem, "left", False, 1) $h_listview_2=ControlGetHandle($w, "",$id_listView );get wrong listvieew handle $itemtext_2=ControlListView ($w, "", $id_listView, "GetText" ,0,0);get wrong text Link to comment Share on other sites More sharing options...
zjsong Posted August 12, 2014 Author Share Posted August 12, 2014 anyone can answer? Link to comment Share on other sites More sharing options...
JohnOne Posted August 12, 2014 Share Posted August 12, 2014 Without having or knowing the software it's very difficult, but I'd say your problem almost certainly lies here... $id_listView="[id:100]" If the ID is changing then obviously you will not get your control. Show the summary tab of listview from window info tool before and after you select new treeview item. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
zjsong Posted August 12, 2014 Author Share Posted August 12, 2014 (edited) Without having or knowing the software it's very difficult, but I'd say your problem almost certainly lies here... $id_listView="[id:100]" If the ID is changing then obviously you will not get your control. Show the summary tab of listview from window info tool before and after you select new treeview item. hi John, the listview ID do not change but its handle and instance changed, and the old listview is hide. Thanks before: >>>> Control <<<< Class: SysListView32 Instance: 1 ClassnameNN: SysListView321 Name: Advanced (Class): [CLASS:SysListView32; INSTANCE:1] ID: 100 Text: Position: 218, 492 Size: 993, 233 ControlClick Coords: 414, 95 Style: 0x50500009 ExStyle: 0x00020000 Handle: 0x000205B0 after: >>>> Control <<<< Class: SysListView32 Instance: 2 ClassnameNN: SysListView322 Name: Advanced (Class): [CLASS:SysListView32; INSTANCE:2] ID: 100 Text: Position: 218, 478 Size: 1057, 247 ControlClick Coords: 102, 48 Style: 0x50500009 ExStyle: 0x00020000 Handle: 0x00020614 I can't get new handle ...... Edited August 12, 2014 by zjsong Link to comment Share on other sites More sharing options...
JohnOne Posted August 12, 2014 Share Posted August 12, 2014 What if you go back to the prior treeview item, does the listview instance return of go to 3? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
zjsong Posted August 13, 2014 Author Share Posted August 13, 2014 What if you go back to the prior treeview item, does the listview instance return of go to 3? No, it always keep instance as 1. When I click new item in TreeView it will create a new instance and new handle for ListView that have same ID, and then those instance/handle always keep their own number. The old listviews are hidden till go back. I just want get handle of 2, 3, 4.... but it only give me handle of 1. Link to comment Share on other sites More sharing options...
JohnOne Posted August 13, 2014 Share Posted August 13, 2014 Then all I can suggest is to keep track of the instance of the control (perhaps in an array) for each treeview item you click on. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
zjsong Posted August 13, 2014 Author Share Posted August 13, 2014 Thank you Link to comment Share on other sites More sharing options...
JohnOne Posted August 13, 2014 Share Posted August 13, 2014 It's also worth having a go at UIAutomation, you'll find UDFs and examples sticky in example scripts. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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