Skip to content

Instantly share code, notes, and snippets.

@leotada
Last active December 13, 2023 15:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leotada/c682188b154f7b93d1ec to your computer and use it in GitHub Desktop.
Save leotada/c682188b154f7b93d1ec to your computer and use it in GitHub Desktop.
Python mouse control on Windows
# controlar o mouse no Windows.
import ctypes
import time # opcional
# see http://msdn.microsoft.com/en-us/library/ms646260(VS.85).aspx for details
def pos(x, y):
ctypes.windll.user32.SetCursorPos(x, y)
def click():
ctypes.windll.user32.mouse_event(2, 0, 0, 0,0) # left down
ctypes.windll.user32.mouse_event(4, 0, 0, 0,0) # left up
def rodar():
for i in range(1000):
pos(i, i)
time.sleep(0.01)
#click()
if __name__ == "__main__":
while 1:
input()
rodar()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment