A Python-based automation tool that moves your mouse cursor in a perfect circle for a specified duration. Built with PyAutoGUI and designed with safety features and interrupt capabilities.
- Circular Movement: Smooth, mathematically precise circular mouse movement
- Duration Control: Configurable animation duration (default: 5 seconds)
- Center Positioning: Automatically centers the circle on current cursor position
- Interrupt Safety: Press ESC to immediately stop movement, or use Ctrl+C
- Position Restoration: Automatically returns cursor to starting position
- Progress Tracking: Real-time progress indicators during animation
- Cross-Platform: Works on Windows, macOS, and Linux
- Python 3.6 or higher
- pip (Python package installer)
-
Clone or download this repository
-
Install dependencies:
pip install -r requirements.txt
-
Run the program:
python main.py
- Position your mouse cursor where you want the center of the circle to be
- Run the script:
python circular_mouse.py - Press ENTER when prompted to start the animation
- Watch your cursor move in a perfect circle for 5 seconds
- Press ESC at any time to interrupt the movement
Key parameters can be modified in circular_mouse.py:
RADIUS = 100 # Circle radius in pixels
DURATION = 5.0 # Animation duration in seconds
FPS = 30 # Frames per second (smoothness)The circular movement uses parametric circle equations:
x = center_x + radius * cos(angle)y = center_y + radius * sin(angle)
Where the angle increments smoothly over time to create fluid motion.
- Fail-safe Protection: PyAutoGUI's built-in corner fail-safe
- Keyboard Interrupts: ESC key and Ctrl+C support
- Position Restoration: Returns cursor to original position
- Error Handling: Graceful error recovery and cleanup
- User Confirmation: Requires explicit confirmation before starting
- PyAutoGUI (≥0.9.54): Cross-platform GUI automation
- keyboard (≥0.13.5): Keyboard event detection for ESC interrupt
| Platform | Additional Notes |
|---|---|
| macOS | No additional setup required |
| Windows | No additional setup required |
| Linux | May require: python3-tk, python3-dev, scrot, python3-xlib |
| Key/Action | Function |
|---|---|
| ENTER | Start circular movement |
| ESC | Interrupt movement immediately |
| Ctrl+C | Force stop program |
| Mouse to corner | PyAutoGUI fail-safe activation |
==================================================
Circular Mouse Movement Automation
==================================================
SAFETY NOTE: This script will control your mouse cursor.
Make sure you're ready before proceeding.
The cursor will move in a circle for 5 seconds.
Press ENTER to start the circular movement (or Ctrl+C to cancel)...
Starting circular movement centered at (640, 360)
Circle radius: 100 pixels
Duration: 5.0 seconds
Press ESC to interrupt the movement at any time...
Starting circular movement...
Time elapsed: 1.0s
Time elapsed: 2.0s
Time elapsed: 3.0s
Time elapsed: 4.0s
Time elapsed: 5.0s
Completed 5.0-second circular movement!
Restoring cursor to original position (640, 360)
Circular movement complete!
Program completed successfully!
Import Errors:
pip install --upgrade pyautogui keyboardPermission Errors on Linux:
sudo pip install -r requirements.txtmacOS Security Permissions:
- Grant accessibility permissions in System Preferences → Security & Privacy → Privacy → Accessibility
Movement Too Fast/Slow:
- Modify the
FPSconstant incircular_mouse.py - Higher FPS = smoother but more CPU intensive
- Lower FPS = less smooth but more efficient
- Screen Recording Demos: Create smooth circular mouse movements for tutorials
- Mouse Testing: Test mouse hardware and software responsiveness
- Automation Testing: Verify cursor tracking in applications
- Screensaver Prevention: Keep system active during presentations
- Accessibility Tools: Automated mouse movement for accessibility needs
RADIUS = 200 # Larger circleDURATION = 10.0 # 10-second animationFPS = 60 # Ultra-smooth 60 FPS movementModify the angle increment calculation:
# For 3 complete rotations over duration
angle_increment = (6 * math.pi) / (DURATION * FPS)Contributions are welcome! Areas for improvement:
- Additional movement patterns (figure-8, spiral, etc.)
- GUI interface for parameter adjustment
- Multiple monitor support
- Movement recording and playback
- Speed ramping (slow start/stop)
This project is open source and available under the MIT License.
This tool is designed for legitimate automation and testing purposes. Users are responsible for complying with their organization's policies and local laws regarding automated mouse control. Always ensure you have proper authorization before running automation scripts on shared or managed systems.
Created with Python 3 • PyAutoGUI • Mathematical Precision