Skip to content
Conduit

skill

usehid

๐ŸŽฎ Cross-platform virtual HID device library for AI agents

jiusanzhou/usehidcommunitylistedunreviewed

Set up

Skills are installed by placing their folder where your agent loads skills.

The download comes from github.com/jiusanzhou/usehid itself, not from our server, so what you get is exactly what its author published.

Install instructions come from the README

Skills do not use an MCP config. Follow the steps in the README below.

README

synced Oct 26, 2026

๐ŸŽฎ useHID

Cross-platform virtual HID device library for AI agents

Crates.io PyPI npm License Platform

useHID lets AI agents control computers like humans do โ€” moving the mouse, typing on the keyboard, pressing gamepad buttons, taking screenshots, and reading UI elements. Built in Rust with bindings for Python, TypeScript, and Go.

from usehid import AgentHID

agent = AgentHID()
agent.execute({"action": "key_combo", "modifiers": ["cmd"], "key": "space"})
agent.execute({"action": "type", "text": "Google Chrome"})
agent.execute({"action": "key_press", "key": "enter"})

โœจ Features

  • ๐Ÿ–ฑ๏ธ Virtual Mouse โ€” Move, click, double-click, drag, scroll
  • โŒจ๏ธ Virtual Keyboard โ€” Type text, press keys, key combinations
  • ๐ŸŽฎ Virtual Gamepad โ€” Joysticks, buttons, triggers
  • ๐Ÿ“ธ Screenshot โ€” Capture full screen or regions as PNG
  • ๐ŸŒณ UI Tree / Accessibility โ€” Read the OS accessibility tree (elements, roles, bounds)
  • ๐Ÿค– Agent-Ready API โ€” Simple JSON interface for LLM agents
  • ๐Ÿฆ€ Pure Rust Core โ€” Safe, fast, zero-copy where possible
  • ๐Ÿ Multi-language โ€” Python, TypeScript, Go bindings

๐Ÿš€ Quick Start

For AI Agents (Recommended)

The AgentHID class provides a JSON-based interface perfect for LLM tool-calling:

from usehid import AgentHID

agent = AgentHID()

# Query screen info
result = agent.execute({"action": "size"})        # Returns: {width: 1920, height: 1080}
result = agent.execute({"action": "position"})    # Returns: {x: 100, y: 200}

# Screenshot
result = agent.execute({"action": "screenshot"})  # Returns: {data: "<base64 PNG>"}
result = agent.execute({"action": "screenshot_region", "x": 0, "y": 0, "width": 400, "height": 300})

# UI Tree (Accessibility)
result = agent.execute({"action": "get_ui_tree", "depth": 3})  # Returns: {tree: {role, title, children, ...}}
result = agent.execute({"action": "find_ui_element", "role": "AXButton", "title": "Submit"})

# Mouse actions
agent.execute({"action": "mouse_move_to", "x": 500, "y": 300})  # Absolute move
agent.execute({"action": "mouse_move", "x": 100, "y": 50})      # Relative move
agent.execute({"action": "mouse_click", "button": "left"})
agent.execute({"action": "mouse_drag_to", "x": 600, "y": 400})  # Drag to position
agent.execute({"action": "mouse_scroll", "delta": -3})

# Keyboard actions
agent.execute({"action": "type", "text": "Hello, World!"})
agent.execute({"action": "key_press", "key": "enter"})
agent.execute({"action": "key_combo", "modifiers": ["ctrl", "shift"], "key": "s"})

Direct Functions (Python)

import usehid

# Screen info
width, height = usehid.size()       # Get screen dimensions
x, y = usehid.position()            # Get mouse position
usehid.move_to(500, 300)            # Move mouse to absolute position

# Screenshot
png_bytes = usehid.screenshot()              # Full screen โ†’ PNG bytes
png_bytes = usehid.screenshot_region(0, 0, 800, 600)  # Region โ†’ PNG bytes

# Accessibility / UI Tree
tree = usehid.get_ui_tree(depth=3)           # Returns dict with role, title, children, bounds...
elements = usehid.find_ui_element(role="AXButton")  # Find matching elements

Direct Device Control

For more control, use the device classes directly:

from usehid import Mouse, Keyboard

mouse = Mouse()
mouse.move_by(100, 50)
mouse.click("left")
mouse.drag(200, 100)   # Drag by relative offset
mouse.scroll(-3)

keyboard = Keyboard()
keyboard.type_text("Hello!")
keyboard.combo(["cmd"], "s")  # Cmd+S to save

๐Ÿ“‹ Supported Actions

Screen/Query

ActionParametersReturnsDescription
sizeโ€”width, heightGet screen dimensions
positionโ€”x, yGet current mouse position

Screenshot

ActionParametersReturnsDescription
screenshotโ€”data (base64 PNG)Capture the full screen
screenshot_regionx, y, width, heightdata (base64 PNG)Capture a screen region

Usage:

# Full screen
result = agent.execute({"action": "screenshot"})
png_base64 = result["data"]

# Region
result = agent.execute({"action": "screenshot_region", "x": 100, "y": 100, "width": 400, "height": 300})

Platform backends: macOS (CGWindowListCreateImage), Linux (ImageMagick import), Windows (GDI BitBlt)

Accessibility / UI Tree

ActionParametersReturnsDescription
get_ui_treedepth?, app?tree (UIElement)Get accessibility tree from focused/named window
find_ui_elementrole?, title?elements (UIElement[])Find matching elements in the focused window

UIElement structure:

{
  "role": "AXButton",
  "title": "Submit",
  "value": null,
  "description": "Submit the form",
  "bounds": {"x": 200, "y": 150, "width": 80, "height": 32},
  "children": [],
  "actions": ["AXPress"]
}

Usage:

# Get full UI tree (depth-limited)
result = agent.execute({"action": "get_ui_tree", "depth": 3})
tree = result["tree"]

# Get UI tree for a specific app
result = agent.execute({"action": "get_ui_tree", "app": "Safari"})

# Find all buttons
result = agent.execute({"action": "find_ui_element", "role": "AXButton"})
buttons = result["elements"]

# Find element by title
result = agent.execute({"action": "find_ui_element", "title": "Save"})

Platform backends: macOS (AXUIElement API), Linux (xdotool), Windows (UI Automation)

โš ๏ธ Requires Accessibility permissions on macOS (System Settings โ†’ Privacy & Security โ†’ Accessibility)

Mouse

ActionParametersDescription
mouse_movex, y, duration?, tween?Move by relative offset
mouse_move_tox, y, duration?, tween?Move to absolute position
mouse_clickbutton?Click (left/right/middle)
mouse_double_clickbutton?Double click
mouse_downbutton?Press and hold
mouse_upbutton?Release
mouse_scrolldeltaScroll wheel (+up/-down)
mouse_dragx, y, button?, duration?, tween?Drag by relative offset
mouse_drag_tox, y, button?, duration?, tween?Drag to absolute position

Keyboard

ActionParametersDescription
typetext, interval?Type a string (interval in ms)
key_presskeyPress and release a key
key_downkeyPress and hold
key_upkeyRelease
key_combomodifiers[], keyKey combination

Supported modifiers: ctrl, shift, alt, cmd/meta/win

Supported keys: a-z, 0-9, enter, escape, backspace, tab, space, up, down, left, right, home, end, pageup, pagedown, delete, insert, f1-f12

Tween Functions

For smooth movement animations, use the tween parameter:

TweenDescription
linearConstant speed (default if duration=0)
ease_in / ease_in_quadSlow start
ease_out / ease_out_quadSlow end
ease_in_out / ease_in_out_quadSlow start and end (default)
ease_in_cubicCubic slow start
ease_out_cubicCubic slow end
ease_in_out_cubicCubic slow start and end
ease_out_elasticElastic bounce effect
ease_out_bounceBounce effect

Failsafe

Emergency stop mechanism - moving mouse to any screen corner triggers failsafe and blocks further actions.

ActionReturnsDescription
failsafe_statusenabled, triggeredCheck failsafe state
failsafe_enableโ€”Enable failsafe (default)
failsafe_disableโ€”Disable failsafe
failsafe_resetโ€”Reset triggered state

Usage:

# Check status
result = agent.execute({"action": "failsafe_status"})
# {success: true, enabled: true, triggered: false}

# If triggered, reset to continue
agent.execute({"action": "failsafe_reset"})

# Disable for specific operations (use with caution!)
agent.execute({"action": "failsafe_disable"})
# ... operations ...
agent.execute({"action": "failsafe_enable"})

Gamepad

ActionParametersDescription
gamepad_pressbuttonPress button
gamepad_releasebuttonRelease button
gamepad_left_stickx, yLeft stick (0-255)
gamepad_right_stickx, yRight stick (0-255)
gamepad_triggersleft, rightTriggers (0-255)

Buttons: a, b, x, y, lb, rb, back, start, guide, left_stick, right_stick, dpad_up, dpad_down, dpad_left, dpad_right


๐Ÿ–ฅ๏ธ Platform Support

PlatformMouseKeyboardGamepadScreenshotUI TreeBackend
macOSโœ…โœ…โš ๏ธโœ…โœ…CGEvent / CoreGraphics / AXUIElement
Linuxโœ…โœ…โœ…โœ…โš ๏ธuhid / ImageMagick / xdotool
Windowsโœ…โœ…โš ๏ธโœ…โœ…SendInput / GDI / UI Automation

โš ๏ธ Gamepad notes:

  • macOS: Requires code signing with com.apple.developer.hid.virtual.device entitlement
  • Windows: Requires ViGEmBus driver

macOS Permissions

useHID requires Accessibility permissions for HID control and UI tree access:

  1. Go to System Settings โ†’ Privacy & Security โ†’ Accessibility
  2. Add your terminal app or the application using useHID

Screenshot capture works without Accessibility permissions. UI Tree / Accessibility features require the permission to read element attributes.

Windows

No special permissions required. Uses Win32 SendInput API for mouse and keyboard.


๐Ÿ“ฆ Installation

Rust

[dependencies]
usehid = "0.1"

Python

pip install usehid

TypeScript / Node.js

npm install usehid

Go

go get go.zoe.im/usehid@latest
import usehid "go.zoe.im/usehid"

๐Ÿงช Examples

Open Chrome and Browse (Agent Test)

cargo run --release -p usehid --example agent_browse

This example demonstrates an AI agent:

  1. Opening Spotlight with Cmd+Space
  2. Typing "Google Chrome" and pressing Enter
  3. Opening a new tab with Cmd+T
  4. Navigating to github.com
  5. Scrolling the page
  6. Performing a search

Basic Mouse Control

cargo run --release -p usehid --example mouse

Keyboard Typing

cargo run --release -p usehid --example keyboard

Screenshot Capture

cargo run --release -p usehid --example screenshot

UI Tree (Accessibility)

cargo run --release -p usehid --example ui_tree

๐Ÿ—๏ธ Architecture

usehid/
โ”œโ”€โ”€ usehid-core/          # Rust core library
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ lib.rs            # Public API
โ”‚   โ”‚   โ”œโ”€โ”€ mouse.rs          # Virtual mouse
โ”‚   โ”‚   โ”œโ”€โ”€ keyboard.rs       # Virtual keyboard
โ”‚   โ”‚   โ”œโ”€โ”€ gamepad.rs        # Virtual gamepad
โ”‚   โ”‚   โ”œโ”€โ”€ screenshot.rs     # Screenshot capture (PNG)
โ”‚   โ”‚   โ”œโ”€โ”€ accessibility.rs  # UI tree / accessibility API
โ”‚   โ”‚   โ”œโ”€โ”€ agent.rs          # JSON API for agents
โ”‚   โ”‚   โ”œโ”€โ”€ screen.rs         # Screen info & mouse position
โ”‚   โ”‚   โ”œโ”€โ”€ failsafe.rs       # Emergency stop mechanism
โ”‚   โ”‚   โ”œโ”€โ”€ tween.rs          # Smooth animation functions
โ”‚   โ”‚   โ”œโ”€โ”€ hid.rs            # HID report descriptors
โ”‚   โ”‚   โ””โ”€โ”€ platform/         # Platform backends
โ”‚   โ”‚       โ”œโ”€โ”€ macos/        # CGEvent + IOHIDUserDevice
โ”‚   โ”‚       โ”œโ”€โ”€ linux.rs      # uhid
โ”‚   โ”‚       โ””โ”€โ”€ windows.rs
โ”‚   โ””โ”€โ”€ examples/
โ”œโ”€โ”€ usehid-python/            # Python bindings (PyO3)
โ”œโ”€โ”€ usehid-node/              # Node.js bindings (napi-rs)
โ””โ”€โ”€ usehid-go/                # Go bindings (CGO)

๐Ÿ”ง Building from Source

# Clone the repository
git clone https://github.com/jiusanzhou/usehid
cd usehid

# Build the core library
cargo build --release

# Run tests
cargo test

# Build Python bindings
cd usehid-python
maturin develop --release

๐Ÿค– OpenClaw Integration

useHID can be integrated with OpenClaw to give AI agents full control over your computer.

Quick Setup

  1. Install useHID:
pip install usehid
  1. Grant Permissions (macOS): System Preferences โ†’ Security & Privacy โ†’ Privacy โ†’ Accessibility

  2. Copy the skill to OpenClaw:

cp -r skills/usehid ~/.openclaw/skills/
  1. Use it:
You: Click the Chrome icon on the dock
OpenClaw: [executes mouse_click at dock position]

You: Type "github.com" and press enter  
OpenClaw: [types text and presses enter]

You: Scroll down slowly
OpenClaw: [executes mouse_scroll multiple times]

Example Commands

User RequestuseHID Action
"Click here"{"action": "mouse_click"}
"Type hello world"{"action": "type", "text": "hello world"}
"Press Enter"{"action": "key_press", "key": "enter"}
"Save the file"{"action": "key_combo", "modifiers": ["cmd"], "key": "s"}
"Scroll down"{"action": "mouse_scroll", "delta": -3}
"Take a screenshot"{"action": "screenshot"}
"What's on screen?"{"action": "get_ui_tree", "depth": 2}
"Find the Submit button"{"action": "find_ui_element", "role": "AXButton", "title": "Submit"}
"Select all and copy"Two actions: Cmd+A then Cmd+C

See skills/usehid/SKILL.md for full documentation.


๐Ÿค Use Cases

  • AI Agents โ€” Let LLMs control desktop applications
  • Browser Automation โ€” Alternative to browser-specific APIs
  • Game Bots โ€” Gamepad simulation for testing
  • Accessibility Tools โ€” Alternative input methods
  • Testing โ€” Automated UI testing without browser dependencies

๐Ÿ”„ Comparison with Other Libraries

Why useHID?

FeatureuseHIDPyAutoGUIenigoautopilot-rsRobotGo
Agent-Ready JSON APIโœ…โŒโŒโŒโŒ
Failsafe (Emergency Stop)โœ…โœ…โŒโŒโŒ
Multi-language BindingsRust/Python/Node/GoPythonRustRustGo
Gamepad Supportโœ…โŒโŒโŒโŒ
Smooth Tween Animationsโœ… (10+ functions)โœ…โŒโŒโœ…
True HID-level Simulationโœ… (Linux uhid)โŒโŒโŒโŒ
Zero C Dependenciesโœ… (macOS/Windows)โŒโŒ (libxdo)โŒโŒ (CGO)
Screenshotโœ…โœ…โŒโœ…โœ…
UI Tree / Accessibilityโœ…โŒโŒโŒโŒ
Image RecognitionโŒโœ…โŒโŒโœ… (OpenCV)
Window ControlโŒโœ… (Win)โŒโŒโœ…

Key Advantages

๐Ÿค– Built for AI Agents

# Other libraries: function calls
pyautogui.moveTo(100, 200)
pyautogui.click()

# useHID: JSON actions (perfect for LLM tool-calling)
agent.execute({"action": "mouse_move_to", "x": 100, "y": 200})
agent.execute({"action": "mouse_click"})

๐Ÿ›ก๏ธ Safety First

  • Built-in failsafe: move mouse to any screen corner to stop all automation
  • Query and control failsafe state via API
  • No accidental runaway scripts

๐ŸŽฎ Unique Gamepad Support

  • Virtual gamepad for game automation and testing
  • Full controller emulation: buttons, sticks, triggers

๐ŸŒ True Multi-language

  • Single Rust core with native bindings
  • No subprocess spawning or IPC overhead
  • Consistent API across Python, Node.js, and Go

โšก Pure Rust Performance

  • No C dependencies on macOS/Windows
  • Memory-safe by design
  • Fast and lightweight

When to Use Others

LibraryBest For
PyAutoGUIScreenshot + image recognition workflows
RobotGoGo projects needing OpenCV integration
enigoRust projects needing Wayland support
autopilot-rsSimple Rust automation with screenshots

๐Ÿ“„ License

MIT License - see LICENSE for details.


๐Ÿ™ Acknowledgments


โ†‘โ†“ navigate openesc close