
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
arduino-hid-controller
Advanced tools
Python library to control Arduino as HID (Keyboard/Mouse) via Serial
Python library for controlling keyboard and mouse through Arduino in HID (Human Interface Device) mode. Provides complete control over input device emulation.
Before using this library, you must upload the HID controller sketch to your Arduino:
Download the sketch file:
Open the sketch in Arduino IDE
Select your board type:
Select the correct port:
Upload the sketch:
pip install arduino-hid-controller
Some mouse functions (particularly absolute positioning) require administrator privileges:
sudo
(note: this may require GUI permissions)# Linux/Mac example
sudo python your_script.py
from arduino_hid_controller import HIDController, KeyboardKey, MouseButton
# Auto-connects to Arduino (make sure sketch is uploaded)
hid = HIDController()
# Keyboard examples (no admin required)
hid.keyboard.start()
hid.keyboard.write("Hello World!")
hid.keyboard.press(KeyboardKey.F12)
# Mouse examples (admin may be required for absolute positioning)
hid.mouse.start()
hid.mouse.move_absolute(500, 300) # Requires admin
hid.mouse.click(MouseButton.LEFT) # Doesn't require admin
# Cleanup
hid.keyboard.stop()
hid.mouse.stop()
Main facade class for device control.
Attributes:
keyboard
- KeyboardController instancemouse
- MouseController instanceMethod | Parameters | Returns | Description |
---|---|---|---|
start() | - | bool | Initialize keyboard |
stop() | - | bool | Stop emulation |
is_started() | - | bool | Check is started emulation |
press(key) | key: str/KeyboardKey | bool | Press key |
release(key) | key: str/KeyboardKey | bool | Release key |
press_and_release(key, delay=0.05) | key: str/KeyboardKey, delay: float | bool | Press and release |
release_all() | - | bool | Release all keys |
Method | Parameters | Description |
---|---|---|
key_combo(keys, delay=0.05) | keys: list, delay: float | Key combination |
write(text) | text: str | Type text |
Method | Parameters | Description |
---|---|---|
start() | - | Initialize mouse |
stop() | - | Stop emulation |
is_started() | - | bool |
press(button) | button: MouseButton | Press mouse button |
release(button) | button: MouseButton | Release mouse button |
click(button) | button: MouseButton | Click mouse button |
Method | Parameters | Description |
---|---|---|
move_relative(x, y) | x: int, y: int | Relative movement |
move_absolute(x, y, duration=1.0) | x: int, y: int, duration: float | Absolute movement |
get_position() | - | Current coordinates |
All methods return True
on success or False
on failure. Possible exceptions:
RuntimeError
- connection issuesValueError
- invalid argumentsSerialException
- communication errorsFunction | Requires Admin | Notes |
---|---|---|
move_absolute() | Yes | Needs screen access |
get_position() | Yes | Needs screen access |
move_relative() | No | - |
All keyboard functions | No | - |
If you get errors about screen access:
sudo python your_script.py
or configure permanent permissions:
sudo usermod -a -G input $USER # For mouse access
sudo reboot
MIT License
FAQs
Python library to control Arduino as HID (Keyboard/Mouse) via Serial
We found that arduino-hid-controller demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.