← 返回
未分类

Android GUI Automation

Automate Android apps via Termux using uiautomator2 or Tasker for clicks, swipes, screenshots, text extraction, price tracking, and scheduled tasks.
使用 Termux 中的 uiautomator2 或 Tasker 自动化 Android 应用,实现点击、滑动、截图、文本提取、价格追踪和定时任务。
smseow001 smseow001 来源
未分类 clawhub v3.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 361
下载
💾 0
安装
1
版本
#latest

概述

Android GUI Automation

让 MiniMax(或其他 MCP Client)通过 MCP 协议直接调用 uiautomator2,像真人一样控制 Android 手机屏幕。

架构

MiniMax API (MCP Client)
    ↓ MCP 调用
uiautomator2-mcp (在 Termux 里跑)
    ↓ uiautomator2
Android 手机屏幕 ← USB/无线 ADB

核心优势:

  • MiniMax 直接理解用户意图
  • MCP Tools 自动暴露所有手机操作能力
  • 45 个现成工具,包括 tap_sequence(复合步骤序列)
  • 不需要写死步骤,AI 自己拆解任务

第一步:Termux 安装

pkg install python python-pip
pip install uiautomator2 uiautomator2-mcp pillow requests schedule
python -m uiautomator2 init

第二步:启动 MCP Server

# 方式A: 直接运行(stdio 模式,AI 通过 stdin/stdout 调用)
uiautomator2-mcp

# 方式B: SSH 远程调用(从其他机器连接手机)
ssh user@phone-ip 'cd /path/to/project && uiautomator2-mcp'

第三步:MiniMax MCP 配置

在 MiniMax MCP 配置里添加:

{
  "mcpServers": {
    "android": {
      "command": "ssh",
      "args": ["user@phone-ip", "uiautomator2-mcp"]
    }
  }
}

45 个可用 MCP Tools

连接 & 设备

Tool说明
------------
list_devices列出 ADB 可见的所有设备
connect连接设备(IP:5555 或自动发现)
device_info获取机型/屏幕/系统版本
current_app获取当前前台 APP

点击 & 滑动

Tool说明
------------
tap点击坐标
double_tap双击坐标
long_tap长按坐标
multi_tap多次点击
swipe滑动(两点之间)
drag拖拽
press_key按键(home/back/enter/power)

输入

Tool说明
------------
input_text输入文字
set_element_text设置元素文字

元素定位

Tool说明
------------
find_element查找元素(text/resourceID/class/xpath)
tap_element查找并点击元素
double_tap_element查找并双击元素
element_exists检查元素是否存在
wait_element等待元素出现

⭐ 复合操作(最强大)

Tool说明
------------
tap_sequence一次执行多步操作序列
// tap_sequence 示例:淘宝搜索 iPhone
{
  "action": "tap_sequence",
  "steps": [
    {"action": "tap_element", "text": "搜索"},
    {"action": "wait", "timeout": 2},
    {"action": "input_text", "text": "iPhone 16 256GB"},
    {"action": "press_key", "key": "enter"},
    {"action": "wait", "timeout": 3},
    {"action": "screenshot", "save_path": "/sdcard/result.png"}
  ]
}

截图 & UI 分析

Tool说明
------------
screenshot截图(可返回 base64 给 AI 分析)
dump_hierarchy获取 XML 界面结构
get_ui_tree获取 JSON 格式完整 UI 树

APP 管理

Tool说明
------------
app_start启动 APP
app_stop停止 APP
app_install安装 APK
app_clear清空 APP 数据
app_info获取 APP 信息

设备控制

Tool说明
------------
screen_on亮屏
screen_off灭屏
unlock解锁
open_notification打开通知栏
get_clipboard读剪贴板
set_clipboard写剪贴板

文件 & Shell

Tool说明
------------
push_file推文件到手机
pull_file从手机拉文件
shell在手机上执行 shell

日志

Tool说明
------------
get_logs读取 logcat 日志
clear_logs清空日志

使用示例

示例1:淘宝搜索商品

用户: "帮我去淘宝搜 iPhone 16 多少钱"

MiniMax MCP 调用:
1. tap_sequence([
     {action:"tap_element", text:"搜索"},
     {action:"input_text", text:"iPhone 16 256GB"},
     {action:"press_key", key:"enter"},
     {action:"wait", timeout:3}
   ])
2. screenshot(inline=true)  →  AI 视觉读价格

示例2:小红书发笔记

用户: "帮我发一条小红书,内容是今天发现超好用的AI工具"

MiniMax MCP 调用:
tap_sequence([
  {action:"tap_element", text:"发布"},
  {action:"wait", timeout:2},
  {action:"tap_element", text:"选择照片"},
  {action:"wait", timeout:1},
  {action:"tap", x:540, y:960},  // 选第一张
  {action:"tap_element", text:"完成"},
  {action:"wait", timeout:1},
  {action:"input_text", text:"今天发现一个超好用的AI工具!#AI工具"},
  {action:"tap_element", text:"发布"},
  {action:"wait", timeout:3}
])

示例3:多平台比价

用户: "帮我对比 iPhone 16 在淘宝、拼多多、京东的价格"

MiniMax 循环调用3次:
for platform in [taobao, pinduoduo, jd]:
  1. app_start(package=platform)
  2. tap_sequence([搜索 → 输入iPhone16 → 等待结果])
  3. screenshot(inline=true) → AI 读价格
汇总 → 生成对比 → 发 Telegram

APP 包名速查

APP包名搜索比价发帖
-----------:----::----::----:
淘宝com.taobao.taobao
拼多多com.xunmeng.pinduoduo
小红书com.xingin.xhs
抖音com.ss.android.ugc.aweme⚠️
京东com.jingdong.app.mall
微信com.tencent.mm

定时任务 & 通知

# crontab 定时执行(Termux 里)
0 9,20 * * * python3 price_monitor.py >> ~/logs/price.log 2>&1
# price_monitor.py — 用 MCP call 包装
import subprocess, json

def mcp_call(tool, **kwargs):
    req = {"jsonrpc":"2.0","method":"tools/call",
           "params":{"name":tool,"arguments":kwargs},"id":1}
    proc = subprocess.Popen(
        ["ssh", "phone-ip", "uiautomator2-mcp"],
        stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True
    )
    out, _ = proc.communicate(input=json.dumps(req)+"\n")
    return json.loads(out)

已知限制

场景支持
------------
标准 UI APP
游戏/Unity APP
银行加固 APP⚠️
滑动验证码⚠️ 需打码平台
人脸验证

参考

  • uiautomator2-mcp: https://pypi.org/project/uiautomator2-mcp/
  • uiautomator2: https://github.com/openatx/uiautomator2
  • 本地脚本: scripts/android_automation.py(独立 Python 版,无需 MCP)

版本历史

共 1 个版本

  • v3.0.0 当前
    2026-05-07 22:16 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

office-efficiency

MiniMax PPT

smseow001
MiniMax PPT生成 - 4套视觉模板,自动对齐圆角、阴影、间距,一键生成结构完整、样式统一的.pptx。
★ 0 📥 1,218
dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 78 📥 182,658
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 681 📥 330,030