-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskip.py
More file actions
52 lines (40 loc) · 1.49 KB
/
Copy pathskip.py
File metadata and controls
52 lines (40 loc) · 1.49 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import time
import threading
from evdev import InputDevice, categorize, ecodes, UInput
# MUDE para o seu teclado correto
# Liste com: ls /dev/input/by-id/
KEYBOARD_PATH = "/dev/input/by-id/usb-USB_USB_Keyboard-event-kbd"
device = InputDevice(KEYBOARD_PATH)
ui = UInput()
running = False
alt_pressed = False
def macro_loop():
global running
while True:
if running:
# Pressiona F
ui.write(ecodes.EV_KEY, ecodes.KEY_F, 1)
ui.write(ecodes.EV_KEY, ecodes.KEY_F, 0)
# Pressiona SPACE
ui.write(ecodes.EV_KEY, ecodes.KEY_SPACE, 1)
ui.write(ecodes.EV_KEY, ecodes.KEY_SPACE, 0)
ui.syn()
time.sleep(0.04) # velocidade (ajuste aqui)
else:
time.sleep(0.1)
threading.Thread(target=macro_loop, daemon=True).start()
print("Pressione ALT + K para ligar/desligar o macro")
for event in device.read_loop():
if event.type == ecodes.EV_KEY:
key = categorize(event)
# Monitora o estado da tecla ALT
if key.keycode in ["KEY_LEFTALT", "KEY_RIGHTALT"]:
if key.keystate == key.key_down:
alt_pressed = True
elif key.keystate == key.key_up:
alt_pressed = False
# Verifica se K foi pressionado enquanto ALT está segurado
if key.keycode == "KEY_K" and key.keystate == key.key_down:
if alt_pressed:
running = not running
print("MACRO ON" if running else "MACRO OFF")