pywinauto自动化控制win32的ui的程序,网上有好多的教程。但是操作dotnet写的winform教程,就少之又少。今天我就来分享我的pywinauto操作dotnet的winform的研究。

我自己写了个dotnet4的winform程序,样子是这样的

在第一个输入框输入文字后,点击“设置”,就能在下面的输入框同时显示

然后,我就打开WinSpy++.exe分析这个dotnet4写的winform,发现层次是这样的:

下图是与以vc写的win32的gui程序的winspy的分析

而参照该博主的博客文章https://blog.csdn.net/qq_37193537/article/details/81206788

winspy++的分析

进行画葫芦的分析dotnet写的winform,代码如下:

from pywinauto.application import Application
app= Application().start("WindowsFormsInput.exe")#.exe的路径是正确的,修改自己的路径
form = app.window_(title_re=u"Form1", class_name="WindowsForms10.Window.8.app.0.141b42a_r16_ad1")# form.print_control_identifiers()

 以下是输出:

E:\py\autogui>python win32dotnet.py
win32dotnet.py:: DeprecationWarning: Method .window_() is deprecated, use .wind
ow() instead.
form = app.window_(title_re=u"Form1", class_name="WindowsForms10.Window.8.app.
.141b42a_r16_ad1")#
Control Identifiers: WindowsForms10.Window..app..141b42a_r16_ad1 - 'Form1' (L88, T88, R388, B388
)
['WindowsForms10.Window.8.app.0.141b42a_r16_ad1', 'Form1', 'Form1WindowsForms10.
Window..app..141b42a_r16_ad1']
child_window(title="Form1", auto_id="Form1", control_type="WindowsFormsInput.For
m1")
|
| Button - 'clear' (L251, T324, R326, B347)
| ['clearButton', 'Button', 'clear', 'Button0', 'Button1']
| child_window(title="clear", auto_id="button2", control_type="System.Windows
.Forms.Button")
|
| Button - '设置' (L162, T324, R237, B347)
| ['Button2', '设置Button', '设置']
| child_window(title="设置", auto_id="button1", control_type="System.Windows.
Forms.Button")
|
| Edit - 'E:\py\autogui\ce.png' (L162, T246, R326, B267)
| ['Form1Edit', 'Edit', 'Form1Edit0', 'Form1Edit1', 'Edit0', 'Edit1']
| child_window(title="E:\py\autogui\ce.png", auto_id="textBox3", control_type
="System.Windows.Forms.TextBox")
|
| Edit - '' (L162, T193, R326, B214)
| ['Form1Edit2', 'Edit2']
| child_window(auto_id="textBox2", control_type="System.Windows.Forms.TextBox
")
|
| Edit - '' (L162, T146, R326, B167)
| ['Form1Edit3', 'Edit3']
| child_window(auto_id="textBox1", control_type="System.Windows.Forms.TextBox
")

初步分析dotnet的win的控件排序与打印的是倒序了。

增加了在第一个Edit中输入字符串:

from pywinauto.application import Application
app= Application().start("WindowsFormsInput.exe")#.exe的路径是正确的,修改自己的路径
form = app.window_(title_re=u"Form1", class_name="WindowsForms10.Window.8.app.0.141b42a_r16_ad1") form.Form1Edit3.type_keys(r"E:\py\autogui\ce.png")

控制点击“设置”按钮

from pywinauto.application import Application
app= Application().start("WindowsFormsInput.exe")#.exe的路径是正确的,修改自己的路径
form = app.window_(title_re=u"Form1", class_name="WindowsForms10.Window.8.app.0.141b42a_r16_ad1")#
form.Form1Edit3.type_keys(r"E:\py\autogui\ce.png")
#form.Button2.click() #同样起作用
form.设置.click()

 

原创-使用pywinauto进行dotnet的winform程序控制(一)的更多相关文章

  1. 使用winform程序控制window服务的操作

    继上篇 c#之添加window服务(定时任务) 基础之上, 这篇文章主要讲述,使用winform程序来控制window服务的安装,启动,停止,卸载等操作 1.在同一个解决方案添加winform项目,如 ...

  2. [原创][开源]SunnyUI.Net, C# .Net WinForm开源控件库、工具类库、扩展类库、多页面开发框架

    SunnyUI.Net, 基于 C# .Net WinForm 开源控件库.工具类库.扩展类库.多页面开发框架 Blog: https://www.cnblogs.com/yhuse Gitee: h ...

  3. 原创+部分引用啦:C# Winform界面中的分隔线问题

    C sharp 中Winform中的控件很多,一个小小的问题居然会绕上一个小弯子,做界面的时候, 你需要在界面上弄一条分隔线,把相关的功能分隔开来,结果原来在其它 IDE编辑器里很容易实现的这个功能, ...

  4. 新的尝试!ComponentOne WinForm 和 .NET Core 3.0

    在微软 Build 2018 开发者大会上,.NET 团队公布了 .NET Core 的下一个主要版本 .NET Core 3.0 的规划蓝图:.NET Core 3将开始支持Windows桌面应用程 ...

  5. Winform自定义控件实例

    本文转自http://www.cnblogs.com/hahacjh/archive/2010/04/29/1724125.html 写在前面: .Net已经成为许多软件公司的选择,而.Net自定义W ...

  6. 解决vs2019中暂时无法为.net core WinForms使用 Designer 的临时方法

    目录 解决vs2019中暂时无法为.net core WinForms使用 Designer 的临时方法 安装 vs 2019 professional/enterprise版本 在vs的设置里,勾选 ...

  7. 基于VLC的播放器开发

    VLC的C++封装 因为工作需要,研究了一段时间的播放器开发,如果从头开始做,可以学习下FFmpeg(http://www.ffmpeg.org/),很多播放器都是基于FFmpeg开发的,但是这样工作 ...

  8. WPF之VLC流媒体播放

    原文:WPF之VLC流媒体播放 最近在做关于在WPF使用VLC流媒体播放的问题,现在可以在WPF中实现VLC本地播放了,流播放解决了,在下面的代码中注释流媒体播放那两段代码,更多的在乎大家摸索了^^, ...

  9. 一个支持 CodeFirst/DbFirst/ModelFirst 的数据库小工具

    一个支持 CodeFirst/DbFirst/ModelFirst 的数据库小工具 Intro DbTool 是一个支持 CodeFirst/DbFirst/ModelFirst 的数据库小工具,原本 ...

随机推荐

  1. Spring boot配置说明

    要加“m”说明是MB,否则就是KB了. -Xms:初始值 -Xmx:最大值 -Xmn:最小值 java -Xms80m -Xmx80m -jar mod.jar 时区设置 java -jar -Dus ...

  2. Linux下Qt5.6 Fcitx无法输入中文输入解决办法

    Qt5.6的解决办法和之前的版本有点不同,方法如下:首先安装 fcitx-frontend-qt5.然后执行: 123 sudo cp /usr/lib/x86_64-linux-gnu/qt5/pl ...

  3. POJ 1328 Radar Installation(经典贪婪)

    Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 54143   Accepted: 12 ...

  4. ASP.NET Core 基本项目目录结构 - ASP.NET Core 基础教程 - 简单教程,简单编程

    原文:ASP.NET Core 基本项目目录结构 - ASP.NET Core 基础教程 - 简单教程,简单编程 ASP.NET Core 基本项目目录结构 上一章节中我们成功创建了一个名为 Hell ...

  5. Angular 请求另一服务的api(请求代理)

    1.edit "start" of your package.json to look below 定义一个叫做start的新命令 "start": " ...

  6. iphone开发技巧整合

    1.NSCalendar用法 -(NSString *) getWeek:(NSDate *)d { NSCalendar *calendar = [[NSCalendar alloc] initWi ...

  7. c# Ajax后台动态分页

    创建WebPager类 public static class WebPager { public static string WebPagerAjax(string Idn, bool IsShor ...

  8. jq自定义下拉菜单,当用户点击非自身元素(下拉菜单)本身时关闭下拉菜单

    jq自定义下拉菜单,当用户点击非自身元素(下拉菜单)本身时关闭下拉菜单 截图: 代码如下: //关闭用户菜单 $(document).mousedown(function(e){ var _con = ...

  9. centos搭建免费的ssl证书,大部分浏览器均支持!(let’s encrypt 的使用记录)

    安装certbot wget https://dl.eff.org/certbot-auto chmod a+x certbot-auto 然后就是通过这个脚本获取证书,安装前先将NGINX 停一下. ...

  10. Flutter 开发环境搭建

    Flutter 开发环境搭建 官方的资料相对还是比较全面的,包含了很多中文的资料信息.官方对咱们国家的开发人员还是很友好的. 安装教程:https://flutter.io/get-started/i ...