-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (28 loc) · 899 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from pynput import keyboard
import pyautogui
import threading
import sys
if len(sys.argv) > 2:
if(sys.argv[1] == "--help" or sys.argv[1] == "-h"):
print("Usage: python3 main.py [SENSIBILITY] \n Default sensitivity is 30")
else:
SENSIBILITY = int(sys.argv[1])
else:
SENSIBILITY = 30
def move_cursor(key):
if key == keyboard.Key.up:
pyautogui.moveRel(0, -SENSIBILITY)
elif key == keyboard.Key.down:
pyautogui.moveRel(0, SENSIBILITY)
elif key == keyboard.Key.left:
pyautogui.moveRel(-SENSIBILITY, 0)
elif key == keyboard.Key.right:
pyautogui.moveRel(SENSIBILITY, 0)
elif key == keyboard.Key.space:
pyautogui.click()
print("space")
def on_press(key):
t = threading.Thread(target=move_cursor, args=(key,))
t.start()
with keyboard.Listener(on_press=on_press) as listener:
listener.join()