简体   繁体   中英

C# GUI automation using PyWinAuto

I was working with GUI automation for visual studio C# desktop application. There I have DataGridView and inside the grid I have combo box and check boxes. I tried to automate these using pywinauto, I can get only grid layout control only and internal things I cant able to get the controls

(I tried with print _control_identifiers() , Swapy, AutoIT Window Info and winspy also..)

anyone plz tell me how to automate visual studio C# DataGridView and its sub controls using pywinauto for desktop application??

The short answer is that there's no good way to automate sub-controls of a DataGridView using PyWinAuto.

If you want to read data out of a DataGridView (eg read the text contents of a cell, or determine whether a checkbox is checked), you are completely out of luck. If you want to control a DataGridView, there are two approaches that you can try:

  • clicking at various coordinate offsets.

  • sending keypresses to it to mimic keyboard navigation.

These may work if your DataGridView has a small amount of data in it, but once the DataGridView starts needing scrollbars you're out of luck. Furthermore, clicking at offsets is sensitive to the sizes of the rows and columns, and if the columns can be resized then this approach will never be reliable.

Try the version 0.6.6 of pywinauto which has better support for datagridview now. https://github.com/pywinauto/pywinauto/releases . Dont forget to use uia backend. Example below

Application(backend="uia")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM