0
点赞
收藏
分享

微信扫一扫

python uiautomation-01环境搭建

1.安装python

下载地址:https://www.python.org/

2.安装uiautomation

安装pip,步骤略(一般装完python已经安装)

打开cmd 执行:pip install uiautomation

3.基本操作

import subprocess
import uiautomation as automation
import time

def main():
subprocess.Popen('redcore.exe') #启动浏览器
time.sleep(1)
redWindow = automation.WindowControl(searchDepth = 1, ClassName = 'Chrome_WidgetWin_1') #取浏览器handle
if not redWindow.Exists(0):
automation.Logger.WriteLine('未找到红芯浏览器,请重试!',automation.ConsoleColor.Yellow)
return
redWindow.ShowWindow(automation.ShowWindow.Maximize) #最大化浏览器
redWindow.SetActive()
time.sleep(1)

# MenuOperation.menuOperation(redWindow) #操作浏览器菜单


login = redWindow.TextControl(Name=u'未登录',searchDepth=3,searchWaitTime=10)

if login.Exists(5):
print("未登录!")
loginImages = redWindow.ImageControl(searchDepth=6,foundIndex=6)
time.sleep(1)
loginImages.Click()
print(loginImages)
time.sleep(2)
redWindow.SendKeys('{alt}{F4}')
time.sleep(2)

if __name__ == '__main__':
main()
input('全部运行完成')

 



举报

相关推荐

0 条评论