关于 android-cli-ui-automation-skill
用于通过命令行自动操作 Android 设备的技能,面向需要完成应用界面任务的 Agent。它强调每次操作后重新观察,并可按界面选择结构化布局或截图方式。
主要功能
- 01启动应用、打开 URL 或安装 APK
- 02读取结构化界面布局
- 03截图并标注可交互目标
- 04通过 adb 执行触控与文本输入
- 05每次操作后重新观察
适用场景
- 01自动完成应用内的界面操作
- 02处理 WebView、地图或自定义画布
- 03在多个已连接设备中指定目标设备
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ takahirom/ android-cli-ui-automation-skill --skill android-cli-ui-automation-skill安装后在 Claude Code 中输入/android-cli-ui-automation-skill确认已加载。
附带文件LICENSEREADME.md
详细介绍
以紧凑的 启动 → 观察 → 操作 → 再观察 循环操控设备,直到达成目标。
结构化界面优先使用 android layout。如果截图模式更快或更可靠,则使用截图模式。
如果连接了多台设备,使用 adb devices -l 获取序列号。将 --device=<serial> 传给 android ...,将 -s <serial> 传给 adb ...。
1. 启动
- 浏览器中的 URL:
adb -s <serial> shell am start -a android.intent.action.VIEW -d '<url>' - 已安装的应用:
adb -s <serial> shell monkey -p <pkg> -c android.intent.category.LAUNCHER 1 - APK 文件:
android run --apks=<path> --device=<serial> [--activity=<name>]
2. 使用 android layout 观察
android layout --device=<serial> --pretty --output=/tmp/ui.json
根据 text、content-desc 或 resource-id 匹配目标。使用节点的 center 作为点击坐标。
每次操作后,都使用所选模式重新观察。仅需查看变化时,android layout --device=<serial> --diff 会很有用。
3. 视觉定位更容易时使用截图模式
以下情况通常更适合使用截图模式:
- WebView 或浏览器页面内容
- 只有图标的自定义视图
- Canvas、地图或游戏界面
- 任何
layout信息杂乱、不完整,或比查看图像更难解读的屏幕
android screen capture --output=/tmp/ui.png --annotate
android screen resolve --screenshot=/tmp/ui.png --string="input tap #N"
标签仅对该截图有效。每次 UI 发生变化后,都要重新截图。
4. 使用 adb shell input 执行操作
adb -s <serial> shell input tap <x> <y>
adb -s <serial> shell input text '<text-with-%s-for-spaces>'
adb -s <serial> shell input swipe <x1> <y1> <x2> <y2> <ms>
adb -s <serial> shell input keyevent <KEYCODE>
示例:adb -s <serial> shell input text 'hello%sworld'
规则
- 每次操作后都要重新观察。坐标和截图标签会立即失效。
- 优先清除阻碍:权限对话框、引导页、更新提示。
- 选择更清晰的观察模式:结构化 UI 使用
layout,视觉 UI 使用截图。
备注
- 不要在地址栏中输入 URL。使用
am start -a VIEW -d '<url>'打开。 - 如果无法确定前台应用,使用
adb -s <serial> shell dumpsys window | rg 'mCurrentFocus|mFocusedApp'检查。
评论
支持 Markdown