Coder Social home page Coder Social logo

mousemove's Introduction

Mouse Activity Script

This Python script continuously moves the mouse cursor to keep the system from entering an idle state. It also detects any keyboard or mouse activity and stops the script once such activity is detected.

Features

  • Continuous Mouse Movement: The script moves the mouse cursor back and forth every second to prevent the system from considering it idle.
  • Activity Detection: The script monitors keyboard presses (specifically the "Escape" key) and mouse button clicks. If any of these activities are detected, the script stops running.
  • Multithreading: The script uses multithreading to run the mouse movement and activity detection simultaneously.

Prerequisites

Ensure you have Python installed on your system. You also need to install the following Python libraries:

  • pyautogui: Used for controlling the mouse.
  • keyboard: Used for detecting keyboard input.
  • mouse: Used for detecting mouse input.

You can install the required libraries using pip:

```bash pip install pyautogui keyboard mouse ```

How to Use

  1. Run the Script:

    Execute the script in your Python environment:

    ```bash python script_name.py ```

    Replace `script_name.py` with the name of your Python file.

  2. Mouse Movement:

    The script will start moving the mouse cursor back and forth every second.

  3. Activity Detection:

    • Press the `Escape` key, click any mouse button, or manually move the mouse to stop the script.
    • The script will detect this activity and stop automatically, printing a message indicating that the script has stopped.

How It Works

  • Thread 1: The `move_mouse()` function runs in a separate thread and is responsible for moving the mouse cursor by 10 pixels to the right and then back to the left every second.
  • Thread 2: The `detect_activity()` function runs in another thread, constantly checking for keyboard or mouse activity. If activity is detected, the `running` flag is set to `False`, stopping both threads.

Example Output

``` Mouse movement script started. Press any key or move the mouse to stop. Mouse or keyboard activity detected. Stopping the script. Script stopped. ```

Notes

  • The script will stop as soon as it detects any of the following:
    • The `Escape` key is pressed.
    • The left or right mouse button is clicked.
    • The mouse is manually moved from its previous position.

License

This project is licensed under the MIT License. You are free to use, modify, and distribute the code as you see fit.


This script is ideal for scenarios where you need to keep your computer awake without manual intervention, such as during long-running processes or downloads.

mousemove's People

Contributors

supphawit-le avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.