当前位置:网站首页>APP自动化uiautomator2获取toast
APP自动化uiautomator2获取toast
2022-08-02 19:38:00 【觅远】
源码:
def get_message(self,
wait_timeout=10,
cache_timeout=10,
default=None):
"""
Args:
wait_timeout: seconds of max wait time if toast now show right now
cache_timeout: return immediately if toast showed in recent $cache_timeout
default: default messsage to return when no toast show up
Returns:
None or toast message
"""自动获取toast,当有toast时,截图保存并语音播报:
import uiautomator2 as u2
import win32com.client
from datetime import datetime
d = u2.connect()
while True:
toast = d.toast.get_message(wait_timeout=5)
if toast:
print(toast) # 打印toast信息
d.screenshot('./IMG/%stoast.jpg' % datetime.now().strftime('%Y%m%d%H%M%S')) # 截图保存
speaker = win32com.client.Dispatch("SAPI.SpVoice") # 语音播放获取到的toast信息
speaker.Speak(toast)
d.toast.reset() # 在验证成功后及时清除缓存边栏推荐
- Based on OpenGL glaciers and firebird (illumination calculation model, visual, particle system)
- 腾讯云孟凡杰:我所经历的云原生降本增效最佳实践案例
- Redis cluster configuration
- Geoserver+mysql+openlayers
- golang刷leetcode 经典(12) 完全二叉树插入器
- 斯堪尼亚SCANIA OTL标签介绍
- 一款好用的FAQ搭建工具
- AI Scientist: Automatically discover hidden state variables of physical systems
- 即时通讯开发移动端网络短连接的优化手段
- 程序员也许都缺一个“二舅”精神
猜你喜欢

4KMILES加入艾盛集团,以更强劲的数字商务能力,加速中国跨境电商的全域全效增长

斯堪尼亚SCANIA OTL标签介绍

光源控制器接口定义说明

Leetcode刷题——字符串相加相关题目(415. 字符串相加、面试题 02.05. 链表求和、2. 两数相加)

idea 配置resin

Redis 5 种数据结构及对应使用场景

ShardingSphere-proxy +PostgreSQL实现读写分离(静态策略)

Based on OpenGL glaciers and firebird (illumination calculation model, visual, particle system)

Kali命令ifconfig报错command not found

Electron使用指南之初体验
随机推荐
腾讯云孟凡杰:我所经历的云原生降本增效最佳实践案例
ALV概念讲解
Electron使用指南之初体验
实战:10 种实现延迟任务的方法,附代码!
golang刷leetcode动态规划(12)最小路径和
AI科学家:自动发现物理系统的隐藏状态变量
即时通讯开发移动端网络短连接的优化手段
健康报告-设计与实现
MySQL安装配置教程(超级详细)
JWT学习
【心理学 · 人物】第一期
OpenCV开发中的内存管理问题
TPAMI2022 | TransCL:基于Transformer的压缩学习,更灵活更强大
VMware虚拟机无法上网
当TIME_WAIT状态的TCP正常挥手,收到SYN后…
姑姑:给小学生出点口算题
银保监会:人身险产品信披材料应由保险公司总公司统一负责管理
es DELETE index 源码分析
TPAMI2022 | TransCL: based on the study the compression of the Transformer, more flexible and more powerful
Dynamically generate different types of orders, how do I deposit to mongo database?