Skip to content

Instantly share code, notes, and snippets.

@LucasFebatis
Created October 19, 2022 23:51
Show Gist options
  • Save LucasFebatis/774334afcc33a2cd822001a74ad9bd28 to your computer and use it in GitHub Desktop.
Save LucasFebatis/774334afcc33a2cd822001a74ad9bd28 to your computer and use it in GitHub Desktop.
Appzinho em Python para manipular clicks automáticos
from pynput.mouse import Button, Controller
import keyboard
import time
mouse = Controller()
print ("Current position: " + str(mouse.position))
isActive = False
# Click the left button
while True:
# try: # used try so that if user pressed other than the given key error will not be shown
if keyboard.is_pressed('q'): # if key 'q' is pressed
print('You Pressed A Key!')
break # finishing the loop
elif keyboard.is_pressed('m'): # if key 'm' is pressed for "Madeira"
isActive = not isActive
print('Auto is (both): ' + str(isActive))
if isActive:
mouse.press(Button.left)
mouse.press(Button.right)
else:
mouse.release(Button.left)
mouse.release(Button.right)
elif keyboard.is_pressed('o'): # if key 'p' is pressed for "Pedra" (Não testado, hehehehhe)
isActive = not isActive
print('Auto is (only left): ' + str(isActive))
if isActive:
mouse.press(Button.left)
else:
mouse.release(Button.left)
elif keyboard.is_pressed('k'): # if key 'p' is pressed for "Pedra" (Não testado, hehehehhe)
isActive = not isActive
print('Auto is (only right): ' + str(isActive))
if isActive:
mouse.press(Button.right)
else:
mouse.release(Button.right)
# except:
# break # if user pressed a key other than the given key the loop will break
time.sleep(0.1)
# Click the right button
# mouse.click(Button.right, 1)
msg = "Finalizado"
print(msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment