pywinauto icon indicating copy to clipboard operation
pywinauto copied to clipboard

Can't get texts from the SysListView32

Open eastam opened this issue 6 years ago • 6 comments

I am trying to do an automation for the stock trade software. One step I want to is to obtain the balance list from a control with type "SysListView32". I can get the itemcount but I can't get the text of items.

Specifications

  • Pywinauto version: 0.6.7
  • Python version and bitness: 3.7.4 32bit version
  • Platform and OS: Win10 The trade software is 32bit version. backend=win32;

Code example

The listview control is with Class: "SysListView32", Instance: 1, control_id: 1567. When I use:

listview=app.top_window.window(control_id=1567, class_name="SysListView32")
items=listview.items()             
item_count=listview.item_count()   # for backend=win32, item_count=10 is correct. for uia, it is 1 (wrong)
texts=items.texts()                  # I got a error here, it says that "RuntimeError: We should never get to this part of ListView.get_item(), retval=0, GetLastError()=0, item_index=0,sub_item_index=0

When I print items, it is a list shows that is a list of ojbects like:

[<pywinauto.controls.win32_controls.ListViewWrapper object at 0x5639B70>,..., <...object at 0x....>]

Steps to Reproduce the Problem

I have searched the web to see some similar issue that may be caused by:

  1. 64bit Python & 32bit program
  2. 32bit Python & 64bit program
  3. backend issue, uia may help

I checked my python environment it is 32bit python installed with anaconda virtual environment and all packages are installed under 32bit setting under conda prompt with "set CONDA_FORCE_32BIT=1“ and conda_info shows "platform: win-32". The packages are all installed to be 32bit packages.

I also checked my trade program, in the explorer task manager, it shows "xxxx (32bit)” Therefore I think it is 32bit program.

I also tried to use 64bit python environment, for the same program. No improvement, it shows the same issue.

I tried different backend and found my program is more suitable for win32 backend. As explained above, when I use win32 backend the item_count is 10 and this is correct. But when I use uia backend, the item_count is 1 and it is not correct. I have 10 items in the list and there are seveal columns in it.

I tried different spy tools for this listview control, it seems that no tool could obtain the content of that listview. One tool shows the listview hierarchy with ListHeader, but no items, like --List1 |--(+)ListHeader (no items listed below)

Only one tool shows the ListHeader and and items below, but still no text content is identified from the listview items, i.e. text: "". One good thing is that when the items are visited in the tools, there is one highlight box around the cells. So the tools locate the cells, but does not extract content correctly. The content are digits in cells. One exception is for each row, the first column is highlighted as the whole row and for all other column they are correct. The tool is called UIASpy whcih is from the internet also. Wired thing is that it seems to explore the UIA controls in some way.

I think the issue maybe is that the listview is self-drawed by the program under a un-standardized condition. But item_count is got and the item is show with <xxxx object at 0x...>. How to deal with this situation? Please offer your help. Thanks in advance. The trade program is TDX trader which is used in Chinese, I can't provide you a sample program because it needs account to login.

eastam avatar Sep 16 '19 06:09 eastam

Hi @eastam many brokers provide demo accounts. Is it possible to create such one for this brokerage?

vasily-v-ryabov avatar Sep 16 '19 16:09 vasily-v-ryabov

They provide demo software and you need to register account with cell phone number. But it is in Chinese. Can anyone of you read it? The website is: http://mock.tdx.com.cn/site/app/mock/index/index.html The software could be downloaded at: http://www.tdx.com.cn/products/mock/tdx_mock.exe

eastam avatar Sep 17 '19 00:09 eastam

Can't reach the website, but I'm able to download the software. Will try the website from another PC later. I think Chrome can translate it with enough degree of quality to understand the minimal registration steps.

vasily-v-ryabov avatar Sep 17 '19 16:09 vasily-v-ryabov

Well, I could reach the initial page of web site, but registration link doesn't work. The initial window also doesn't have such kind of control.

From my experience with explorer.exe I can say that SysListView32 can't be automated using backend="win32". So backend="uia" should be the only way.

vasily-v-ryabov avatar Sep 29 '19 17:09 vasily-v-ryabov

Did you find a solution for this issue? I am having the same problem, only that when I use "uia" backend, everything freezes, and fails, because there are many elements...

martinlombana avatar Nov 16 '20 19:11 martinlombana

Did you find a solution for this issue? I am having the same problem, only that when I use "uia" backend, everything freezes, and fails, because there are many elements...

I have same situation, any solution?

burkvt avatar Mar 24 '24 08:03 burkvt