PythonUIAutomation4Windows 介绍
使用Python封装Windows UIAutomation API,支持MFC,Windows@H_502_3@ Forms,WPF,Metro,Qt,Firefox等程序的UI自动化,使得编写UI自动化脚本非常容易,支持平台Windows 7/8/8.1/10。
!python3
-- coding:utf-8 --
import time@H_502_3@ import subprocess@H_502_3@ import automation
def AutomateNotepad():@H_502_3@ automation.ShowDesktop()
打开notepad
subprocess.Popen(‘notepad’)
查找notepad, 如果name有中文,python2中要使用Unicode
window = automation.WindowControl(searchDepth = 1, ClassName = ‘Notepad’,@H_502_3@ SubName = ‘无标题 - 记事本’)
查找edit
edit = window.EditControl()@H_502_3@ time.sleep(1)@H_502_3@ edit.SetValue(‘hi你好’)@H_502_3@ edit.SendKeys(‘{Ctrl}{End}{Enter 2}Welcome to use Python UIAutomation for@H_502_3@ Windows{! 4}{ENTER}’, 0.1)@H_502_3@ time.sleep(1)@H_502_3@ window.Close()@H_502_3@ time.sleep(1)@H_502_3@ buttonNotSave = window.ButtonControl(SubName = ‘不保存’)@H_502_3@ buttonNotSave.Click()
or send alt+n to not save and quit
automation.SendKeys(‘{ALT}n’)
if name == ‘main’:@H_502_3@ AutomateNotepad()
其它例子:
使用python
UIAutomation从QQ2016(8.0)群界面获取所有群成员详细资料
PythonUIAutomation4Windows 官网
http://git.oschina.net/yinkaisheng/PythonUIAutomation4Windows
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。