Skip to content

This is a Python-based mobile phone automation control script, through scrcpy to achieve mobile screen projection, and the use of ADB and OpenCV to achieve automated operations.

License

Notifications You must be signed in to change notification settings

1194951803/PhoneAutoControl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

手机自动化控制脚本

这是一个基于Python的手机自动化控制脚本,通过scrcpy实现手机投屏,并使用ADB和OpenCV来实现自动化操作。

功能特点

  • 自动连接手机并启动投屏
  • 支持定时启动指定应用
  • 通过图像识别实现精确点击
  • 可配置的任务计划
  • 详细的运行日志

环境要求

  • Python 3.8+
  • ADB 工具
  • Scrcpy
  • OpenCV

安装步骤

  1. 安装必要的Python包:
pip install -r requirements.txt
  1. 确保已安装ADB和Scrcpy,并添加到系统环境变量

  2. 手机开启USB调试模式

使用方法

  1. 将需要识别的目标图片放入 images 目录
  2. config.yaml 中配置任务计划
  3. 运行脚本:
python main.py

目录结构

├── main.py # 主程序
├── config.yaml # 配置文件
├── requirements.txt # 依赖包
├── src/
│ ├── adb.py # ADB控制模块
│ ├── scrcpy.py # 投屏控制模块
│ └── cv.py # 图像识别模块
└── images/ # 目标图片目录

使用说明:

  1. 将需要点击的目标图片(如按钮、图标等)保存到 images 目录下
  2. config.yaml 中配置任务计划,包括:
    • 应用包名
    • 执行时间
    • 点击动作及对应的图片
  3. 运行 main.py 启动自动化控制

这个实现方案的特点是:

  1. 模块化设计,便于维护和扩展
  2. 完善的错误处理和日志记录
  3. 配置驱动,便于修改任务
  4. 使用OpenCV实现精确的图像识别和点击

建议后续改进:

  1. 添加图像识别的容错机制
  2. 增加更多类型的操作(如滑动、长按等)
  3. 添加失败重试机制
  4. 实现GUI界面,方便配置和监控

About

This is a Python-based mobile phone automation control script, through scrcpy to achieve mobile screen projection, and the use of ADB and OpenCV to achieve automated operations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages