A simple Python-based automation tool designed to simulate random mouse movements and clicks. It includes a safety fail-safe and an acoustic alarm when the execution is interrupted.
- Python 3.x: Core logic and execution.
- PyAutoGUI: For controlling mouse movement and click events.
- Playsound3: To trigger audio alerts.
- Built-in Libraries:
osfor path handling,timefor execution delays, andrandomfor coordinate generation.
- Random Movement: Generates random coordinates within a specific range (X: 200-1200, Y: 200-650) to keep the cursor active.
- Interactive Input: Prompts the user in the terminal to choose whether the bot should perform clicks (
Y/N) before starting. - Fail-Safe System: Uses PyAutoGUI's built-in fail-safe. Moving the mouse to any corner of the screen safely stops the script.
- Audio Alert: Automatically plays an
alarm.mp3file when theFailSafeExceptionis triggered.
The project is organized into specific archives:
mouse_bot.py: The main entry point containing the automation loop, coordinate logic, and exception handling.alarm.mp3: The audio file required in the same directory to be played upon script termination.
- Automation Basics: Handling mouse events and movements programmatically.
- Exception Handling: Using
try/exceptblocks to manage graceful exits (catchingpyautogui.FailSafeException). - Path Management: Dynamically resolving absolute file paths using the
osmodule to ensure the alarm plays regardless of where the script is called from.
- GUI for setting coordinate boundaries and sleep timers.
- Support for multiple monitor setups.
- Add customized movement patterns (e.g., circles or squares).
Install dependencies:
This project requires pyautogui and playsound3. Install them via pip:
pip install pyautogui playsound3