You can use Python to simulate mouse movements and prevent your computer from locking. Here’s a simple script using the pyautogui
library that moves the mouse slightly every few minutes to keep your PC active:
First, you need to install the pyautogui
library. You can do this by running:
pip install pyautogui
Then, you can use the following script to move the mouse slightly every few minutes:
import pyautogui
import time
def move_mouse():
while True:
current_pos = pyautogui.position()
pyautogui.moveTo(current_pos[0] + 1, current_pos[1] + 1)
time.sleep(0.5)
pyautogui.moveTo(current_pos)
time.sleep(300) # wait for 5 minutes (300 seconds)
if __name__ == "__main__":
move_mouse()