Skip to main content

Library for emulate mouse and keyboard on raspberry pi zero

Project description

HID python library for emulating mouse and keyboard on PI.

Setup

  1. Install apt dependencies
sudo apt-get update
sudo apt-get install -y git python3-pip python3-venv
  1. install usb gadget module

  2. Create virtual environment

python3 -m venv ~/venv
source ~/venv/bin/activate
  1. Install zero-hid with pip
pip3 install zero-hid
  1. Reboot if not already!

Usage

Note: You should connect the data usb port (left one) to the raspberry, and NOT the power port

  • Control mouse
from zero_hid import Mouse
m = Mouse()
for i in range(5):
    m.move(10, 10)
  • Control keyboard
from zero_hid import Keyboard

k = Keyboard()
k.type('Hello world!')

Features

  • Relative / Absolute mouse movements
  • Left / Right / Middle click
  • Scrolling
  • Typing
  • Hot keys
  • Drag and Drop
  • LEDs status
  • Easy to setup
  • Comprehensive Testing

Examples

see examples

Tests

Raspberry Pi Model Raspbian Version Kernel Version Date of Testing
Raspberry Pi 4 Raspbian 12 (bookworm) 6.6.31 04/08/2024
Raspberry Pi 4 Raspbian 12 6.1 01/01/2023
Raspberry Pi Zero Raspbian 5.10 - 01/01/2023

Gotachas


Absolute mouse used only for positining. use relative mouse for clicking etc. see examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zero_hid-1.0.1.tar.gz (21.3 kB view hashes)

Uploaded Source

Built Distribution

zero_hid-1.0.1-py3-none-any.whl (36.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page