原创-使用pywinauto进行dotnet的winform程序控制(一)
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程序控制(一)的更多相关文章
- 使用winform程序控制window服务的操作
继上篇 c#之添加window服务(定时任务) 基础之上, 这篇文章主要讲述,使用winform程序来控制window服务的安装,启动,停止,卸载等操作 1.在同一个解决方案添加winform项目,如 ...
- [原创][开源]SunnyUI.Net, C# .Net WinForm开源控件库、工具类库、扩展类库、多页面开发框架
SunnyUI.Net, 基于 C# .Net WinForm 开源控件库.工具类库.扩展类库.多页面开发框架 Blog: https://www.cnblogs.com/yhuse Gitee: h ...
- 原创+部分引用啦:C# Winform界面中的分隔线问题
C sharp 中Winform中的控件很多,一个小小的问题居然会绕上一个小弯子,做界面的时候, 你需要在界面上弄一条分隔线,把相关的功能分隔开来,结果原来在其它 IDE编辑器里很容易实现的这个功能, ...
- 新的尝试!ComponentOne WinForm 和 .NET Core 3.0
在微软 Build 2018 开发者大会上,.NET 团队公布了 .NET Core 的下一个主要版本 .NET Core 3.0 的规划蓝图:.NET Core 3将开始支持Windows桌面应用程 ...
- Winform自定义控件实例
本文转自http://www.cnblogs.com/hahacjh/archive/2010/04/29/1724125.html 写在前面: .Net已经成为许多软件公司的选择,而.Net自定义W ...
- 解决vs2019中暂时无法为.net core WinForms使用 Designer 的临时方法
目录 解决vs2019中暂时无法为.net core WinForms使用 Designer 的临时方法 安装 vs 2019 professional/enterprise版本 在vs的设置里,勾选 ...
- 基于VLC的播放器开发
VLC的C++封装 因为工作需要,研究了一段时间的播放器开发,如果从头开始做,可以学习下FFmpeg(http://www.ffmpeg.org/),很多播放器都是基于FFmpeg开发的,但是这样工作 ...
- WPF之VLC流媒体播放
原文:WPF之VLC流媒体播放 最近在做关于在WPF使用VLC流媒体播放的问题,现在可以在WPF中实现VLC本地播放了,流播放解决了,在下面的代码中注释流媒体播放那两段代码,更多的在乎大家摸索了^^, ...
- 一个支持 CodeFirst/DbFirst/ModelFirst 的数据库小工具
一个支持 CodeFirst/DbFirst/ModelFirst 的数据库小工具 Intro DbTool 是一个支持 CodeFirst/DbFirst/ModelFirst 的数据库小工具,原本 ...
随机推荐
- WPF 窗体基类实现的体验及实现回车到下一控件
原文:WPF 窗体基类实现的体验及实现回车到下一控件 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/jsyhello/article/details ...
- jquery validate 详细说明
jQuery校验 官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation 一导入js库 <script src=&q ...
- 3D场景中的鼠标响应事件
原文:3D场景中的鼠标响应事件 今天要讲的是3D场景中的鼠标响应事件的处理,首先Button的响应是大家熟知的,只要加上一个click事件,然后写一个响应的处理时间就行了.对于二维平面上的一些控件也很 ...
- Linux性能测试 top命令
原文地址:http://www.cnblogs.com/txw1958/archive/2012/07/25/linux-top-command.html top命令是Linux下常用的性能分析工具, ...
- 零元学Expression Design 4 - Chapter 3 看小光被包围了!!如何活用「Text On Path」设计效果
原文:零元学Expression Design 4 - Chapter 3 看小光被包围了!!如何活用「Text On Path」设计效果 本章将教大家如何活用「Text On Path」,做出文绕图 ...
- NS2网络模拟(1)-延迟
1: #NS2_有线部分\EndDelay.awk 2: 3: BEGIN { 4: #Initialize the variable 5: MaxID = 0; 6: i = 0; 7: } 8: ...
- 带农历日历的DatePicker控件!Xamarin控件开发小记
原文:带农历日历的DatePicker控件!Xamarin控件开发小记 闲来无事开发了个日期选择控件,感兴趣的同学前往: https://github.com/MatoApps/Mato.DatePi ...
- uboot初体验-----趣谈nand设备发起的浅显理解
1 选择Uboot版本号 2 移植uboot至console正常work 3 制造uImage和使用uboot指南 4 写NFC驱动器 5 uboot从nand启动引导系统 1 选择Uboot版本号 ...
- VisualSVN-6.0.1Patch just for VS2017补丁原创发布
VisualSVN-6.0.1Patch_justforVS2017补丁原创发布 一切尽在发布中.
- php 二维数组相同值 相加
array(3) { [0]=> array(2) { ["sourcesid"]=> int(1) ["addusernum"]=> str ...