Last active
December 13, 2023 15:09
-
-
Save leotada/c682188b154f7b93d1ec to your computer and use it in GitHub Desktop.
Python mouse control on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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