原创-使用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 的数据库小工具,原本 ...
随机推荐
- python 垃圾回收装置
转载: https://www.cnblogs.com/pinganzi/p/6646742.html 简要描述Python的垃圾回收机制(garbage collection). 答案 这里能说的很 ...
- Windows安装Linux子系统--安装GUI界面
原文:Windows安装Linux子系统--安装GUI界面 前段时间发现Windows可以安装Linux子系统了,恰逢电脑换了固态,还没装Linux,不如趁机体验一番! 1.准备工作 1.1.打开 ...
- [C/C++]_[VS2010使用源代码UTF8中国字符串转码ANSI问题]
场景: 1.思想vs设置源文件UTF8编码,的代码串中国出现在它必须是utf8编码.不幸的是没有,假设源代码出现在中国字符串,在内存公交码ANSI编码. Unicode(UTF8) 代码页(65001 ...
- JS 实现Map
function Map() { this.arr = new Array(); var struct = function(key, value) { this.key = key; this.va ...
- 基于VC面部识别软件(识别出人脸特征)
最近在学校MFC和Opencv,毕业只是做面部识别软件,所以写一个,我觉得很简单. 第一个VC组态opencv.不用说.非常easy,网上资料非常多,然后就是设计界面啦,这个全然凭个人喜好了,我设计的 ...
- 存储过程和输出分辨率表菜单JSON格式字符串
表的结构,如以下: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo] ...
- swagger ui 值类型形参加文字注释
例: @ApiImplicitParams({ @ApiImplicitParam(paramType = "query", name = "indexCondition ...
- Python第一个基本教程4章 词典: 当指数不工作时也
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32 Type "copyri ...
- 专访Jeffrey Richter:Windows 8是微软的重中之重
Jeffrey Richter 以其多本 Windows 核心技术的经典著作而闻名,同时,他深入掌握微软的 .NET 等一系列核心技术,他所创办的 Wintellect 公司与微软有密切的合作关系,他 ...
- AngularJS 页面计算
<div ng-app="multipliedCaculateApp" ng-controller="multipliedCaculateController as ...