harmony-hdc

v2026.09.24

HarmonyOS device control and UI automation via raw HDC commands. Use for device/emulator discovery, USB or TCP connection, app launch/force-stop, tap/swipe/keyevent/text input, screenshots, UI dump, file transfer, and HDC troubleshooting.

GitHub
安装命令
npx skhub add httprunner/harmony-hdc
Markdown
SKILL.md

Harmony HDC

Reference for controlling HarmonyOS devices with raw hdc commands.

Execution Constraints

  • Use hdc -t <device_id> whenever more than one device is connected.
  • Confirm screen resolution before coordinate actions: hdc -t DEVICE shell wm size.
  • Ask for missing required inputs before executing (device id, bundle/ability, coordinates, file paths).
  • Surface actionable stderr on failure (authorization, cable/network, tcp mode).

Device And Server

# Start HDC server
hdc start

# Stop HDC server
hdc kill

# List targets
hdc list targets

# Target a specific device
hdc -t DEVICE <command>

Connection

# Connect over TCP
hdc tconn <ip>:<port>

# Disconnect target
hdc -t DEVICE tdis

Device State

# Device model/system info
hdc -t DEVICE shell param get const.product.model
hdc -t DEVICE shell param get const.ohos.fullname

# Screen size
hdc -t DEVICE shell wm size

# Foreground focus window
hdc -t DEVICE shell hidumper -s WindowManagerService -a '-a'

# Run raw shell command
hdc -t DEVICE shell <command>

App Lifecycle

# List installed bundles
hdc -t DEVICE shell bm dump -a

# Start an ability
hdc -t DEVICE shell aa start -a <ability_name> -b <bundle_name>

# Start by URI
hdc -t DEVICE shell aa start -U <uri>

# Force-stop app by bundle
hdc -t DEVICE shell aa force-stop <bundle_name>

Input Actions

# Tap
hdc -t DEVICE shell uitest uiInput click X Y

# Double tap
hdc -t DEVICE shell uitest uiInput click X Y && sleep 0.1 && hdc -t DEVICE shell uitest uiInput click X Y

# Long press
hdc -t DEVICE shell uitest uiInput longClick X Y

# Swipe
hdc -t DEVICE shell uitest uiInput swipe X1 Y1 X2 Y2 [duration_ms]

# Key event
hdc -t DEVICE shell uitest uiInput keyEvent Back
hdc -t DEVICE shell uitest uiInput keyEvent Home
hdc -t DEVICE shell uitest uiInput keyEvent Enter

Text Input

# Text input (Harmony text input supports UTF-8)
hdc -t DEVICE shell uitest uiInput inputText "hello world"

Screenshot And UI Dump

# Capture screenshot on device
hdc -t DEVICE shell snapshot_display -f /data/local/tmp/screen.jpeg

# Pull screenshot to local
hdc -t DEVICE file recv /data/local/tmp/screen.jpeg ./screen.jpeg

# Dump UI tree (JSON)
hdc -t DEVICE shell uitest dumpLayout -p /data/local/tmp/layout.json
hdc -t DEVICE file recv /data/local/tmp/layout.json ./layout.json

File Transfer

# Push file to device
hdc -t DEVICE file send ./local.file /data/local/tmp/remote.file

# Pull file from device
hdc -t DEVICE file recv /data/local/tmp/remote.file ./remote.file

App Install And Uninstall

# Install HAP
hdc -t DEVICE install /path/to/app.hap

# Install with replace
hdc -t DEVICE install -r /path/to/app.hap

# Uninstall by bundle
hdc -t DEVICE uninstall <bundle_name>

Common KeyEvents

KeyEventDescription
BackBack button
HomeHome button
EnterEnter/confirm
PowerPower button
VolumeUpVolume up
VolumeDownVolume down
发现
标签

此技能尚未发布标签。

版本
最新版本元数据

版本

v2026.09.24

发布时间

2026年9月24日

分类

未分类

许可证

MIT

源路径

harmony-hdc

默认分支

main

最新提交

a2f2c13

Tree SHA

961f316