Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: simulate_movement.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- This script emulates user interaction by automatically moving the cursor on the screen at predefined intervals.
- It serves as a tool for mimicking user activity in scenarios such as preventing system idle timeouts, maintaining application sessions, or testing user interface responsiveness.
- Requirements:
- - Python must be installed on the system.
- - The pyautogui library must be installed.
- You can install it using this pip command:
- 'pip install pyautogui'
- - The script should be executed on a platform that supports graphical interfaces, such as Windows, macOS, or Linux with X11.
- Functions:
- - simulate_activity():
- This function continuously moves the cursor in a tiny square pattern at predefined intervals, effectively simulating user activity.
- Usage:
- 1. Ensure Python and the pyautogui library are installed on your system.
- 2. Download the simulate_movement.py script to a location on your computer.
- 3. Open a command prompt or terminal window.
- 4. Navigate to the directory where the script is located.
- 5. Run the script by executing the command: python simulate_movement.py.
- 6. The script will start simulating cursor movement in the background.
- 7. To stop the script, press Ctrl+C in the command prompt or terminal window.
- Additional Notes:
- - This script is intended for scenarios where it's necessary to prevent system idle timeouts, maintain active sessions, or test user interface responsiveness.
- - Adjustments to the movement step size (MOVEMENT_STEP) and delay (MOVEMENT_DELAY) can be made to customize the behavior of cursor movement.
- - While running, the script does not produce any visible output or indication of activity, making it discreet and suitable for background operation.
- """
- import time
- import pyautogui
- # Constants
- SLEEP_DURATION = 60 # Seconds
- MOVEMENT_STEP = 1 # Pixels
- MOVEMENT_DELAY = 0.0001 # Seconds
- # Loop indefinitely until interrupted
- try:
- while True:
- # Sleep for the specified duration
- time.sleep(SLEEP_DURATION)
- # Move the cursor in a tiny square pattern
- pyautogui.move(-MOVEMENT_STEP, 0, duration=MOVEMENT_DELAY) # Left
- pyautogui.move(0, -MOVEMENT_STEP, duration=MOVEMENT_DELAY) # Up
- pyautogui.move(MOVEMENT_STEP, 0, duration=MOVEMENT_DELAY) # Right
- pyautogui.move(0, MOVEMENT_STEP, duration=MOVEMENT_DELAY) # Down
- except KeyboardInterrupt:
- # Handle keyboard interrupt (Ctrl+C)
- print("Script terminated by user.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement