Skip to content

Instantly share code, notes, and snippets.

@gh0st
Last active February 4, 2021 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gh0st/2cb7132247703fb1a61304d11c560026 to your computer and use it in GitHub Desktop.
Save gh0st/2cb7132247703fb1a61304d11c560026 to your computer and use it in GitHub Desktop.
A script that programmatically moves your mouse for you.
from random import *
import win32api, win32con, time, Tkinter as tk
def click(x, y):
# cursor move
win32api.SetCursorPos((x, y))
# click event call
# win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
# win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
while True:
# get screen size
root = tk.Tk()
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
# pass random value to axis
x = randint(screen_height, screen_width)
y = randint(screen_height, screen_width)
click(x, y)
print('I am moving to x = ', x, ' and y = ', y)
time.sleep(5) # call every 5 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment