当前位置:网站首页>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() # 在验证成功后及时清除缓存边栏推荐
- 4 kmiles join YiSheng group, with more strong ability of digital business, accelerate China's cross-border electricity full domain full growth
- Translate My Wonderful | July Moli Translation Program Winners Announced
- 牛客题目——滑动窗口的最大值、矩阵最长递增路径、顺时针旋转矩阵、接雨水问题
- shell:条件语句
- J9 digital theory: the Internet across chain bridge has what effect?
- 【心理学 · 人物】第一期
- 腾讯云孟凡杰:我所经历的云原生降本增效最佳实践案例
- PG 之 SQL执行计划
- AI Scientist: Automatically discover hidden state variables of physical systems
- Detailed explanation of common examples of dynamic programming
猜你喜欢
随机推荐
【LeetCode】622. 设计循环队列
B站HR对面试者声称其核心用户都是生活中的Loser
光源控制器接口定义说明
Geoserver + mysql + openlayers problem
ssh configuration
服务器Centos7 静默安装Oracle Database 12.2
【LeetCode】1161. 最大层内元素和
4 kmiles join YiSheng group, with more strong ability of digital business, accelerate China's cross-border electricity full domain full growth
idea 配置resin
A Review of Nature Microbiology: Focusing on the Algae--Ecological Interface of Phytoplankton-Bacteria Interactions
基于 flex 布局实现的三栏布局
MySQL安装时一直卡在starting server
Geoserver+mysql+openlayers
汇编实例解析--利用tcb,tss,全局tss,ldt管理任务实现任务切换
【心理学 · 人物】第一期
Redis 5 种数据结构及对应使用场景
【LeetCode】1374. 生成每种字符都是奇数个的字符串
技术分享 | Apache Linkis 快速集成网页IDE工具 Scriptis
实战:10 种实现延迟任务的方法,附代码!
聊一聊 AS 的一些好用的功能









