1

I am trying to get the content of a table within a GridCtrl control as shown in the screenshot below.

enter image description here

I have found through spy++ that the control containing the table is CVirtualGridCtrl.

enter image description here

But how can I get the content of the table?

app = pywinauto.Application().Connect(path = "xiadan.exe")
control = app[u'网上股票交易系统5.0'].CVirtualGridCtrl
control.PrintControlIdentifiers()

If I run the above code, I will get the following output:

enter image description here

Having searched and test for a long time, I still have no clue. Could someone kindly give me a hint? Thanks a lot.


Edit: Really appreciate your quick response @vasily-ryabov. I have tried as you suggested, unfortunately there is no recognizable control to get the numbers I want.

enter image description here

Does this mean that it is then impossible to get the content of the cells? I have also tried right clicked on the control, but there is no interested short-cut operation.

tusonggao
  • 31
  • 5
  • Did you try to use `Inspect.exe` instead of Spy++? as provided [here](https://pywinauto.readthedocs.io/en/latest/getting_started.html). – Vasily Ryabov Sep 27 '17 at 19:17
  • I'm afraid grids are not supported by Win32 API backend (which is default one). But UI Automation API backend has more chances to recognize the cells. – Vasily Ryabov Sep 27 '17 at 19:18
  • Thanks for your kindly answer @vasily-ryabov. I have tried as you said in the question. – tusonggao Sep 28 '17 at 01:55
  • Looks like UIA backend won't help. If it's standard MFC GridCtrl class, it needs to add special window message handlers on app side + implementing custom GridWrapper in pywinauto (or as a monkey patch). I made it at my previous job, but it was kept privately. So I can advice you on this way, but can't do all the job. Sorry. It would be first public example to implement custom control support. – Vasily Ryabov Sep 28 '17 at 10:23

1 Answers1

1

You can try to use clipboard to get grid data.

control.type_keys('^A^C')
data = pywinauto.clipboard.GetData()
shidenggui
  • 11
  • 2