Re: [Pywinauto-users] Automate selection of Treeview items for .Net Framework 4 using pywinauto
Status: Alpha
Brought to you by:
mcmahon_m
From: Mark Mc M. <mtn...@gm...> - 2011-01-09 01:04:06
|
Hi, Replying to myself... (still no solution though) On Sat, Jan 8, 2011 at 8:54 AM, Mark Mc Mahon <mtn...@gm...> wrote: > Hi, > > Sorry for the delay in getting back to you - and just a very short > answer for now... > > On Thu, Jan 6, 2011 at 3:19 AM, Amal Mohammadi <ama...@gm...> wrote: >> Hi All, >> >> I am trying to automate a .Net Framework 4 application. >> I need to automate the selection of a subItem of a treeview. >> >> Please note that I have already done the following change in my >> common_controls.py: >> class TreeViewWrapper(HwndWrapper.HwndWrapper): >> "Class that wraps Windows TreeView common control" >> friendlyclassname = "TreeView" >> windowclasses = ["SysTreeView32", >> r"WindowsForms\d*\.SysTreeView32\..*","TTreeView", >> "TreeView20WndClass","WindowsForms10.Window.8.app.0.310f4af_r18_ad1"] >> >> ######## Script ######## >> app1=application.Application.start("application.exe") >> app1= application.Application.connect(path="application.exe") >> WindowHandle=findwindows.find_windows(class_name_re = >> "WindowsForms10.Window.8.app.0.310f4af_r18_ad1",top_level_only =False) >> TreeViewHandle=WindowHandle[2] # which I believe is the handle of my >> treeview box. >> tree_item = controls.common_controls.TreeViewWrapper(TreeViewHandle) >> Properties =tree_item.GetProperties() >> ############### >> >> At this point I receive an ERROR message: >> Traceback (most recent call last): >> File "<pyshell#33>", line 1, in <module> >> Properties =tree_item.GetProperties() >> File "C:\Python25\lib\pywinauto\controls\common_controls.py", line >> 906, in GetProperties >> props = super(TreeViewWrapper, self).GetProperties() >> File "C:\Python25\lib\pywinauto\controls\HwndWrapper.py", line 647, >> in GetProperties >> props[propname] = getattr(self, propname)() >> File "C:\Python25\lib\pywinauto\controls\common_controls.py", line >> 885, in Texts >> texts = [self.WindowText(), self.Root().Text()] >> File "C:\Python25\lib\pywinauto\controls\common_controls.py", line >> 611, in Text >> return self._readitem()[1] >> File "C:\Python25\lib\pywinauto\controls\common_controls.py", line >> 859, in _readitem >> raise ctypes.WinError() >> WindowsError: [Error 0] The operation completed successfully. >> > Can you let me know which version of Pywinauto you are using - the line numbers do not match up against mine. > I hate when that happens: A Windows API returns an error result - but > then when you ask windows for the error information - it tells you > "The operation completed successfully". :( > > For now I guess that it may be because your TreeView does not have a > single root element (thanks for the bitmap). > Actually my code DOES work (in a limited way) for a treeview with multiple root elements (though by default it will just work with the first one), so this is not the problem afterall. > I haven't had a chance to look into this yet. Is your application > freely available to download - or is it possible for you to create a > test app for me? > If you have control over the source - then maybe you could try adding > a dummy root item to the treeview to see if that solves the problem > (temporarily) > I don't have a VS 2010 installed, so if you could point me to a sample app that would be great. > >> Thanks Thanks Mark |