Skip to content

Instantly share code, notes, and snippets.

@lorne-luo
Created February 11, 2020 22:07
Show Gist options
  • Save lorne-luo/f7def680ba16c190aec4fe4e35cbec98 to your computer and use it in GitHub Desktop.
Save lorne-luo/f7def680ba16c190aec4fe4e35cbec98 to your computer and use it in GitHub Desktop.
Mouse control on Windows
# controlar o mouse no Windows.
# https://stackoverflow.com/questions/4263608/ctypes-mouse-events
# see http://msdn.microsoft.com/en-us/library/ms646260(VS.85).aspx for details
import ctypes
import time # opcional
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 move(x, y):
ctypes.windll.user32.mouse_event(1, 1, 1, 0, 0)
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