简体   繁体   English

使用PyWinAuto的C#GUI自动化

[英]C# GUI automation using PyWinAuto

I was working with GUI automation for visual studio C# desktop application. 我正在使用Visual Studio C#桌面应用程序的GUI自动化。 There I have DataGridView and inside the grid I have combo box and check boxes. 那里有DataGridView,网格内部有组合框和复选框。 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 我试图使用pywinauto将它们自动化,我只能得到网格布局控件,而内部的东西我无法获得控件

(I tried with print _control_identifiers() , Swapy, AutoIT Window Info and winspy also..) (我尝试使用print _control_identifiers(),Swapy,AutoIT Window Info和winspy。)

anyone plz tell me how to automate visual studio C# DataGridView and its sub controls using pywinauto for desktop application?? 谁能告诉我如何使用pywinauto对桌面应用程序自动化Visual Studio C#DataGridView及其子控件?

The short answer is that there's no good way to automate sub-controls of a DataGridView using PyWinAuto. 简短的答案是,没有使用PyWinAuto自动化DataGridView子控件的好方法。

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. 如果您想从DataGridView中读取数据(例如,读取单元格的文本内容,或确定是否选中了复选框),则完全不走运。 If you want to control a DataGridView, there are two approaches that you can try: 如果要控制DataGridView,可以尝试两种方法:

  • 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. 如果您的DataGridView中包含少量数据,这些方法可能会起作用,但是一旦DataGridView开始需要滚动条,您就不走运了。 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. 尝试pywinauto的0.6.6版本,该版本现在对datagridview有更好的支持。 https://github.com/pywinauto/pywinauto/releases . https://github.com/pywinauto/pywinauto/releases Dont forget to use uia backend. 不要忘记使用uia后端。 Example below 下面的例子

Application(backend="uia")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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