您的位置:首页 >聚焦 >

#Uiautomation# 基于Uiautomation的微信自动化

2023-01-12 13:04:15    来源:程序员客栈

“文章所涉及内容更多来自网络,在此声明,并感谢知识的贡献者!”

UI自动化—

UI编程包括但不限于UI界面的开发,UI界面的测试。而本系列文章的主要侧重于UI界面的自动化操作。通过一段代码实现电脑自行点击、打开某文件或者修改某进程的操作。


(相关资料图)

UI控件识别

UiSpy 下载

(23条消息) windows 技术篇 - uispy 工具获取和使用,windows窗口属性快捷查看工具_挣扎的蓝藻的博客-CSDN博客_uispy

https://blog.csdn.net/qq_38161040/article/details/105491034

FlatUInspect 源码下载

https://github.com/FlaUI/FlaUInspect

FlatUInspect编译运行

FlatUInspect 使用说明

https://zhuanlan.zhihu.com/p/563909940?utm_id=0

FlatUInspect 微信控件层次

控件识别工具Inspect.exe下载

https://www.shuzhiduo.com/A/6pdDZNkDJw/

Window Inspector 下载

https://www.jb51.net/softs/457644.html

locale库

import locale

#获取系统语言

if (locale.getdefaultlocale()[0] =="zh_CN"):

pass

subprocess库

启动程序

import subprocess

subprocess.Popen("3dmark-setup.exe")

Uiautomation库

查找物件:

1、WindowContrl(searchDepth,ClassName,SubName) 查找窗口中的程序,如果有中文则需用Unicode;可用window.Exists(maxSearchSeconds)来判断此窗口是否存在;

2、EditControl(searchFromControl) 查找编辑位置,找到后可用DoubleClick()来改变电脑的focus;edit.SetValue("string")输入值;

3、MenuItemControl(searchFromControl,Name) 查找菜单按钮;

4、ComboBoxControl(searchFromControl,AutomationI) 查找下拉框,然后在此基础上用Select("name")方法来选择需要的选项;

5、BottonControl(searchFromControl,Name,SubName) 查找按钮;

6、automation.FindControl(firefoxWindow,

lambdac:(isinstance(c, automation.EditControl) or isinstance(c,automation.ComboBoxControl)) and c.Name == "Enter your search term") 按条件搜索handle

点击操作:

单击:.Click()

双击:.DoubleClick()

Click() 点击;

RighClik() 右键点击;

DoubleClick()

SendKeys() 发送字符;

SetValue() 传值,一般对EditControl用;

Win32API.SendKeys("string") 如果已在编辑位置,则可用此方法来输入值,{Ctrl}为ctrl键,其他类似;{@ 8}格式可输入8个@,对于数字也可实现此功能,但对于字母不能...;

切换窗口

import uiautomation as auto

window=auto.WindowControl(ClassName="CabinetWClass",searchDepth=1) #控制面板窗口

window.SwitchToThisWindow() # 切换窗口

窗口最大化:

window =auto.WindowControl(ClassName="CabinetWClass", searchDepth=1)

window.Maximize()

窗口操作

subprocess.Popen("Name")   用进程打开程序;

window.Close()         关闭窗口;

window.SetActive()     使用;

window.SetTopMost()     设置为顶层

window.ShowWindow(uiautomation.ShowWindow.Maximize) 窗口最大化

window.CaptureToImage("Notepad.png") 截图;

uiautomation.Win32API.PressKey(uiautomation.Keys.VK_CONTROL) 按住Ctrl键

uiautomation.Win32API.ReleaseKey(uiautomation.Keys.VK_CONTROL)释放Ctrl键

automation.GetConsoleWindow() #return console window that runs python,打开控制台

automation.Logger.ColorfulWriteLine("\nIwill open Notepad andautomate it. Please wait for a while.") 控制台传值(彩色字体),普通传值用WriteLine;

automation.ShowDesktop() 显示桌面;

微信自动化

获取好友列表

https://zhuanlan.zhihu.com/p/474166048

获取微信好友名单,可指定标签 & 全部

https://gitcode.net/mirrors/Frica01/Wechat_mass_msg?utm_source=csdn_github_accelerator

微信好友列表获取(存储到txt中)

https://blog.csdn.net/m0_67391377/article/details/126065428

python基于pywinauto实现PC端自动化 python操作微信自动化

https://blog.51cto.com/u_15354476/3767938

微信群发消息,获取群通讯录名单

https://www.fdsml.com/zh/438398.html

Python 实现获取微信好友信息

https://www.cnblogs.com/swjian/p/10597690.html

微信好友列表获取

https://www.pudn.com/news/62e3f4b5864d5c73ac26b03a.html

自动发送微信消息

参考资料

(23条消息) Python UI自动化 编程(一) UIAutomation_OKKLES的博客-CSDN博客_uiautomation

https://blog.csdn.net/weixin_43393800/article/details/119105108

Python使用uiautomation实现Windows平台自动化 - ooops! - 博客园 (cnblogs.com)

https://www.cnblogs.com/jyang/p/11679828.html

(23条消息) python UIAutomator2使用教程_Jepson2017的博客-CSDN博客_uiautomator2

https://blog.csdn.net/d1240673769/article/details/113809889

开源自己用python封装的一个Windows GUI(UIAutomation)自动化工具,支持MFC,WindowsForms,WPF,Metro,Qt - YinKaisheng - 博客园 (cnblogs.com)

https://www.cnblogs.com/Yinkaisheng/p/3444132.html

桌面应用自动化python——uiautomation API 如何找元素 - 白灰 - 博客园 (cnblogs.com)

https://www.cnblogs.com/baihuitestsoftware/articles/9340462.html

UIAutomation使用(一) -蜗牛学苑 (woniuxy.cn)

https://www.woniuxy.cn/article/253

用开源uiautomation自动化操作火狐 - 知乎 (zhihu.com)

https://zhuanlan.zhihu.com/p/30409594

Python下编写Windows自动化测试软件 - 简书 (jianshu.com)

https://www.jianshu.com/p/be3c46c7a905

python:获取微信好友列表信息(二)进行导出微信好友到csv数据读取与处理

https://blog.csdn.net/seoyundu/article/details/81543756

关键词: 好友列表 切换窗口 自动化操作

相关阅读