当前位置:网站首页>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() # 在验证成功后及时清除缓存边栏推荐
猜你喜欢
随机推荐
SQL 入门之第一讲——MySQL 8.0.29安装教程(windows 64位)
Geoserver + mysql + openlayers problem
Geoserver+mysql+openlayers2
聊一聊 AS 的一些好用的功能
磁盘分区的知识
Detailed explanation of common examples of dynamic programming
el-tree渲染大量数据的解决方案(不通过懒加载)
让你的应用完美适配平板
openlayers版本更新差别
Three.js入门
2022-08-01
Introduction of uncommon interfaces of openlayers
es 读流程源码解析
脑机接口003 | 马斯克称已实现与云端的虚拟自己对话,相关概念股份大涨
Flutter with internationalized adapter automatically generated
SQL Server实现group_concat功能
B站HR对面试者声称其核心用户都是生活中的Loser
溜不溜是个问题
Brain-computer interface 003 | Musk said that he has realized a virtual self-dialogue with the cloud, and related concept shares have risen sharply
软考 ----- UML设计与分析(下)









