A lightweight, ultra-high precision AI virtual mouse for Windows with decoupled ergonomic gestures, zero click drift, and sub-pixel multi-tier ballistics.
Most open-source virtual mice suffer from critical usability flaws:
- Severe cursor jitter when trying to click small buttons.
- Downward cursor drop when curling fingers to click.
- Sluggish cursor latency caused by heavy artificial delays in libraries like PyAutoGUI.
- 100% CPU lock & privacy issues because the webcam runs continuously.
AI Virtual Mouse is engineered from the ground up to solve every single one of these problems:
| Feature | Standard GitHub Virtual Mice | AI Virtual Mouse (This Repo) |
|---|---|---|
| Cursor Control Engine | pyautogui (Laggy, 10ms artificial delay) |
Native Win32 C API (Near 0.001ms hardware latency) |
| Click Drift / Drop | β Drops 50β100px when curling finger | β 0.0px Drift (Pre-click freeze & decoupled tracking) |
| Jitter vs Latency | β Shaky OR slow moving average | β Multi-tier Precision Ballistics (1.8px deadzone) |
| Safety Guard | β Accidental clicks when moving/resting | β Open-Hand Verification (Fist/rest = Clicks disabled) |
| Webcam Standby | β Camera locked forever, 25% CPU | β 0.0% CPU Standby (Camera freed when inactive) |
| Windows Taskbar Reach | β Hand falls off camera boundary | β Ergonomic Margin Buffer (Full reach without hand contortion) |
flowchart TD
Webcam[("πΉ HD Webcam (DirectShow)")] --> PreFilter["π Pre-Filter (Sub-Pixel Temporal Low-Pass)"]
PreFilter --> MP["π€ MediaPipe HandLandmarker (Model Complexity 1)"]
MP --> Anchor["π Rigid Knuckle Anchor (Middle MCP + PIP)"]
Anchor --> CheckHand{"β Is Hand Open?"}
CheckHand -- No (Fist/Resting) --> IdleState["βΈοΈ Safe Mode (Clicks Disabled)"]
CheckHand -- Yes --> CheckIndex{"π Is Index Bent?"}
CheckIndex -- No --> MoveMode["π±οΈ Move Cursor"]
CheckIndex -- "Yes (< 0.22s)" --> ClickMode["π Instant Left Click"]
CheckIndex -- "Yes (>= 0.22s)" --> DragMode["β Drag & Hold (Knuckle Bound)"]
MoveMode --> Ballistics["π― Multi-Tier Ballistics Engine\n(Deadzone 1.8px | Micro-Aim <30px | Glide >30px)"]
DragMode --> Ballistics
Ballistics --> Win32["β‘ Windows user32.dll (SetCursorPos / mouse_event)"]
ClickMode --> Win32
Tip
The cursor is guided by your Middle Finger & Palm Base. The Index Finger functions purely as the physical mouse button!
| Gesture | Action | Description |
|---|---|---|
| Middle Finger / Hand | Move Cursor | Smooth, liquid glide across your entire monitor |
| Open Hand + Tap Index Finger | Left Click | Quick downward tap & release (like a physical mouse button) |
| Open Hand + Double Tap Index | Double Click | Two quick consecutive taps |
| Open Hand + Hold Index Bent | Drag & Hold | Hold index bent (>0.2s) to drag windows/files; straighten to release |
| Open Hand + Thumb-Middle Pinch | Right Click | Tap thumb tip to middle finger tip for context menu |
| Middle + Ring Fingers Together | Scroll | Move hand up to scroll up, move down to scroll down |
| Hand Closed / Fist | Resting | Clicks are strictly disabled while hand is relaxed or closed |
| Hotkey | Action |
|---|---|
Ctrl + Alt + M or F8 |
Toggle Tracking ON / OFF (Instant standby) |
Ctrl + Alt + Q |
Exit Application |
H (inside preview) |
Hide/Show Camera HUD (Runs headless in background) |
S (inside preview) |
Toggle Audio Feedback (Soft chimes for clicks & status) |
Ensure Python 3.10+ is installed on Windows.
git clone https://github.com/RMNO21/ai-virtual-mouse.git
cd ai-virtual-mouse
pip install -r requirements.txtDouble-click run.bat or execute:
python virtual_mouse.pyPress F8 or Ctrl + Alt + M to activate tracking!
Fine-tune every aspect of the engine to match your preferences:
{
"start_active": false,
"hotkeys": {
"toggle": "ctrl+alt+m",
"toggle_alternative": "f8",
"exit": "ctrl+alt+q"
},
"camera": {
"device_id": 0,
"width": 640,
"height": 480,
"fps": 60
},
"interaction": {
"margin_left": 0.15,
"margin_right": 0.15,
"margin_top": 0.15,
"margin_bottom": 0.20,
"speed_multiplier": 1.15,
"pinch_threshold": 0.38,
"release_threshold": 0.52,
"drag_hold_delay": 0.22,
"scroll_sensitivity": 30.0
},
"filter": {
"deadzone": 1.8,
"min_alpha": 0.09,
"max_alpha": 0.88,
"precision_range": 30.0,
"speed_range": 140.0
},
"ui": {
"sound_effects": true,
"show_preview": true,
"preview_width": 380,
"preview_height": 285
}
}- MediaPipe: 3D Hand Landmark regression model (Complexity 1)
- OpenCV: Camera frame acquisition with Windows DirectShow (
CAP_DSHOW) - Win32 API: Direct low-level C mouse control via
ctypes.windll.user32 - Keyboard: System-wide low-latency global hotkey hooking
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
Distributed under the MIT License. See LICENSE for more information.
Made with β€οΈ by RMNO21