当前位置: 首页 > news >正文

Android自动化AirScript

官网:http://airscript.cn/
一个基于Python编程、面向Android、Windows、iPhone等端的自动化脚本执行工具,可以使用在线Web页面进行调试开发,进阶地可以使用Pycharm或VSCode进行复杂脚本开发。拥有完善的py标准库和airscript动作库,可以嵌入js、java等语言进行开发,支持yolo图像训练融合,支持在线检索页面结构生成代码,支持项目脚本多端同步等功能。

一、运行环境

  1. 安装Python
    python官网:https://www.python.org/downloads/
    建议下载 3.8.10版本

  2. 安装PyCharm
    pycharm官网:https://www.jetbrains.com/pycharm/download/
    建议下载最新的社区版本

  3. 安装AirScript插件
    插件分享:https://pan.baidu.com/s/1UGM6ucM_Wn7X4RiAQm7q9g?pwd=pggv
    插件安装:打开pycharm,左上角进设置,点插件,从本地磁盘安装,选择zip文件(不要解压)
    在这里插入图片描述

  4. 手机安装执行器APP
    下载地址:http://airscript.cn/
    手机进入点击下载。或电脑打开,手机扫码下载。
    下载完成后,进入APP,授予无障碍权限,其他权限确认允许。

二、新建项目

安装好插件后重启pycharm,左上角文件-AirScript-新建项目,按表单填写
在这里插入图片描述

三、设备连接

新窗口打开刚才新建的项目,左上角文件-AirScript-设备管理-添加设备
设备名称随意,设备地址在手机APP-开发者,设备端口默认9096
在这里插入图片描述

四、运行demo

需要保证手机和电脑网络处在同于局域网

  1. 可以pycharm运行
    在这里插入图片描述

  2. 也可以网页,电脑浏览器打开,IP:端口,在IDEA中编辑运行
    在这里插入图片描述

  3. 代码确定后,在手机端点击项目执行

  4. 附demo

import time
from airscript.action import touch
# 启动
from airscript.node import Selector
from airscript.system import Media
from airscript.system import R
# 开始吧
from airscript.ui.dialog import toast# class listener:
#     def prepare(self,player):
#         # 获取音频时长
#         dur = player.getDuration()
#         # 带监听器,我们需要调用start方法
#         player.start()
#     def completion(self):
#         print('播放完毕')# Media.play(R(__file__).res('/media/letsgo.mp3'),listener())time.sleep(1)
def open_viewer_list(open_num):# 观众列表while not Selector().id('com.tencent.qqmusic:id/mlive_top_guest_num').visible(True).find():passSelector().id('com.tencent.qqmusic:id/mlive_top_guest_num').click().find()# 真爱粉丝while not Selector().text('真爱粉丝').depth(12).visible(True).find():passSelector().text('真爱粉丝').depth(12).click().find()time.sleep(1)if open_num > 5:# 加载榜单 - 日榜toast('加载全部粉丝中', 500)n = 6while n:while not Selector().id('js_scroll_container').type('View').visible(True).find():passSelector().id('js_scroll_container').type('View').click().slide(10).find()n -= 1Selector().id('js_scroll_container').type('View').click().slide(-100).find()toast('加载完成', 1000)def slip_viewer_list(cnt):while cnt > 0:touch.down(640, 1930)touch.move(640, 1749, 200)touch.up(640, 1749)time.sleep(0.1)cnt -= 1# # 启动APP
# Intent.run('com.tencent.qqmusic')
# time.sleep(2)
# 位置判断
if not Selector().id('com.tencent.qqmusic:id/jy_').visible(True).find() and not Selector().id('com.tencent.qqmusic:id/mlive_view_pager').visible(True).find():toast('先回到首页', 2000)# # 进直播TAB# while not Selector().id('com.tencent.qqmusic:id/jy_').desc('直播').visible(True).find():#     pass# Selector().id('com.tencent.qqmusic:id/jy_').desc('直播').click().find()# 等待选厅
if Selector().id('com.tencent.qqmusic:id/jy_').desc('直播').visible(True).find():toast('开始选厅', 3000)time.sleep(0.5)
# 打开日榜列表
open_viewer_list(6)
# 获取头像view列表 长度
while not Selector().id('js_scroll_container').child(2).child(1).child().find():pass
fav_selector_len = 0
if Selector().id('js_scroll_container').child(2).child(1).child().find_all()[0].childCount>0:fav_selector_len = len(Selector().id('js_scroll_container').child(2).child(1).child().find_all())
# 私信个数
do_work_cnt = 0
while do_work_cnt < fav_selector_len:time.sleep(1)# 点击头像Selector().id('js_scroll_container').child(2).child(1).child().find_all()[do_work_cnt].child(2).click()# 点击私信while not Selector().id('com.tencent.qqmusic:id/mlive_info_card_neutral_layout').find():passSelector().id('com.tencent.qqmusic:id/mlive_info_card_neutral_layout').click().find()# 输入while not Selector().id('com.tencent.qqmusic:id/dsy').desc('消息').find():passtime.sleep(1)Selector().id('com.tencent.qqmusic:id/dsy').desc('消息').input('xxxx').find()# 发送while not Selector().id('com.tencent.qqmusic:id/dub').text('发送').find():passSelector().id('com.tencent.qqmusic:id/dub').text('发送').click().find()toast(f'已发{str(do_work_cnt + 1)}/{str(fav_selector_len)}->' + Selector().id('com.tencent.qqmusic:id/dv0').type('TextView').find().text, 1000)time.sleep(1)# 返回语音厅nextSelector().id('com.tencent.qqmusic:id/dt4').depth(5).click().find()open_viewer_list(do_work_cnt + 1)slip_viewer_list(do_work_cnt - 3)do_work_cnt += 1

文章转载自:

http://47kPS75g.zyLzk.cn
http://bsj9kamr.zyLzk.cn
http://sRFt245U.zyLzk.cn
http://FV8bG6cd.zyLzk.cn
http://Gu7sv3Ch.zyLzk.cn
http://NMPUfuHv.zyLzk.cn
http://jl0bxMvM.zyLzk.cn
http://Yu79Vg5W.zyLzk.cn
http://GylvyDiB.zyLzk.cn
http://rmvfrU1V.zyLzk.cn
http://tWoudrO8.zyLzk.cn
http://UxWde6zK.zyLzk.cn
http://Nc1667v9.zyLzk.cn
http://Ot8rew1x.zyLzk.cn
http://AQGuEv2X.zyLzk.cn
http://HknzK0Ub.zyLzk.cn
http://X3H9aWKc.zyLzk.cn
http://jgGRsjDK.zyLzk.cn
http://Fi3hZzTy.zyLzk.cn
http://SJ0nzDRo.zyLzk.cn
http://5r4xguFa.zyLzk.cn
http://DgRBWGmB.zyLzk.cn
http://8UzfPT4h.zyLzk.cn
http://xldDL7Wz.zyLzk.cn
http://RqniUCAt.zyLzk.cn
http://85CTCNGu.zyLzk.cn
http://04yTtFqH.zyLzk.cn
http://A36SPsjP.zyLzk.cn
http://Ypf3yZT3.zyLzk.cn
http://xdaGeTgH.zyLzk.cn
http://www.dtcms.com/a/245427.html

相关文章:

  • Appium+python自动化(二十)-- Monkey日志
  • ATM 模拟器 Golang 程序--示例
  • 油烟净化设备安装规范
  • 基于SpringBoot的校园网上求职系统设计与实现
  • 双系统(win+linux)根目录扩容(不掉GPU驱动)
  • 【leetcode】226. 翻转二叉树
  • 一分钟了解MCP
  • 无人机安防系统是什么?主流无人机安防平台有哪些?
  • iOS App上线前的安全防线:项目后期如何用Ipa Guard与其他工具完成高效混淆部署
  • @RequestBody和@ResponseBody注解的作用是什么
  • 告别手动做PPT!4款AI工具实现自动化生成
  • 使用 VLC Media Player 轻松提取视频中的音频文件
  • Python 实现 Web 请求与响应
  • AI 工具打造专业级 PPT 配图:从文字到视觉的高效转化指南
  • 关键领域软件测试新范式:如何在安全合规前提下提升效率?
  • 岗位竞聘竞选报告个人简历PPT模版分享
  • xhtml2pdf中文屏幕溢出问题
  • 【数据传输常用命令】:服务器与本地之间的数据传输
  • 服务器-客户端下kafka的消息处理流程
  • SpreadJS 中 HTML Canvas 的性能优势深度解析
  • 基于 Nginx 服务器的泛域名 SSL 证书申请与部署
  • 自建RustDesk服务器
  • 基于YOLOv11与单目测距的实战教程:从目标检测到距离估算
  • Java反射机制深度解析与实战应用
  • Linux中升级或者切换python版本
  • 数据集-目标检测系列- 孔雀 数据集 peacock >> DataBall
  • 华为云Flexus+DeepSeek征文 | 弹性算力实战:Flexus X实例自动扩缩容策略优化
  • [论文阅读] 系统架构 | 零售 IT 中的微服务与实时处理:开源工具链与部署策略综述
  • ROS2双目相机标定与测距全流程详解:从原理到实践
  • MemVid:信息存储的未来?创新还是“视频噱头”?