Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pynput import keyboard //you used pynput right??
- from pynput.mouse import Button, Controller
- mouse = Controller() //mouse is easier to type than Controller....
- def on_press(key):
- if format(key.char) == 'w': //checks for your key
- mouse.position = (400,200) //changes mouse position
- if key == keyboard.Key.esc: //if you press escape you quit the program
- return False
- else:
- return True
- def listen():
- with keyboard.Listener( //start the listener. this is a deamon that registers keyboard events and uses minimal cpu
- on_press=on_press) as listener:
- listener.join()
- listen() //starts the listen script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement