-
Notifications
You must be signed in to change notification settings - Fork 6
/
auto_m2.py
26 lines (21 loc) · 829 Bytes
/
auto_m2.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
from pynput import keyboard
import pyautogui
import time
def auto_m2(toggle: bool, is_target_active: bool, am2_keycode: object=keyboard.Key.alt_gr) -> None:
prev_press = time.time()
def on_press(key):
nonlocal prev_press
if toggle.value:
if is_target_active.value:
current_press = time.time()
if key == am2_keycode:
if (current_press - prev_press) <= 0.3:
pyautogui.mouseDown(button="right")
prev_press = current_press
else:
pyautogui.mouseUp(button="right")
prev_press = current_press
else:
return False
with keyboard.Listener(on_press=on_press) as listener:
listener.join()