##Structure (suggested)**
Hand-Controlled-Cursor/
│
├── main.py
├── requirements.txt
└── README.md
- main.py → Your Python code.
- requirements.txt → List of required packages.
- README.md → Setup and usage guide.
pip install opencv-python
pip install mediapipe
pip install pyautogui
pip install pynput
pip install numpy
This project allows you to control your mouse cursor using hand gestures via your webcam. You can move the cursor, click, scroll, and even perform drag-and-drop—all using your hands, without a physical mouse.
- ✌️ Move mouse with index finger
- 🤏 Click with pinch (thumb + index)
- ✋ Scroll up/down
- 🎮 Smooth AI-like movement for games and applications
- Works on Windows and Linux (Python 3.9+)
Follow these steps to get this project running on your system:
Make sure Python 3.9+ is installed. You can download it from python.org.
Check the version in terminal:
python --versionOpen VS Code terminal and run:
[git clone https://github.com/YOUR_USERNAME/Hand-Controlled-Cursor.git
cd Hand-Controlled-Cursor](https://github.com/shafayat83/Virtual-Mouse.git)Install the required Python packages:
pip install -r requirements.txtThis will install:
- OpenCV (
opencv-python) - Mediapipe (
mediapipe) - PyAutoGUI (
pyautogui) - Pynput (
pynput) - Numpy (
numpy)
- Open VS Code.
- Go to File → Open Folder and select the project folder.
- Ensure the Python interpreter in VS Code is set to the Python version you installed (3.9+). Check in bottom-right corner → select Python 3.9.x.
- Open
main.py. - Press
F5or run in terminal:
python main.py-
A window will open showing your webcam feed.
- Move your index finger → cursor moves.
- Pinch thumb + index → click.
- Press
ESC→ exit program.
-
You can add gestures for:
- Right-click
- Drag & drop
- Scroll
-
Adjust distances in code for sensitivity and smoothness.
- If you get errors like
module 'mediapipe' has no attribute 'solutions'→ Make sure mediapipe is updated:
pip install --upgrade mediapipe- If cursor jitters → increase smoothing by adding a moving average for coordinates.
- Ensure no other program is using the webcam.
This project is open-source. Feel free to use and modify it.