Skip to content

Instantly share code, notes, and snippets.

@ppartarr
Created October 12, 2020 16:49
Show Gist options
  • Save ppartarr/80eef4ae97e50c28cb255a7f38dfb865 to your computer and use it in GitHub Desktop.
Save ppartarr/80eef4ae97e50c28cb255a7f38dfb865 to your computer and use it in GitHub Desktop.
Arbitrarily move the mouse to a random location on screen
import win32api
import time
import random
import logging
# 1920x1080 resolution
xLow = 0
xHigh = 1920
yLow = 0
yHigh = 1080
logging.basicConfig(filename="moveMouse.log", level=logging.DEBUG)
try:
print("Starting move mouse...")
while True:
x = random.randint(xLow, xHigh)
y = random.randint(yLow, yHigh)
print("move mouse to x: {0}, y: {1}".format(x, y))
win32api.SetCursorPos((x, y))
# sleep for 5 min
time.sleep(300)
except Exception as e:
logging.info(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment