forked from nimaid/LPHK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kb.py
52 lines (37 loc) · 896 Bytes
/
kb.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import ms
import sys
if sys.platform == 'win32':
import system_apis.keyboard_win as keyboard_api
else:
import system_apis.keyboard_unix as keyboard_api
pressed = set()
def sp(name):
if "mouse_" in name:
return name
return keyboard_api.sp(name)
def press(key):
pressed.add(key)
if type(key) == str:
if "mouse_" in key:
ms.press(key[6:])
return
keyboard_api.press(key)
def release(key):
pressed.discard(key)
if type(key) == str:
if "mouse_" in key:
ms.release(key[6:])
return
keyboard_api.release(key)
def release_all():
for key in pressed.copy():
release(key)
def tap(key):
if type(key) == str:
if "mouse_" in key:
ms.click(key[6:])
return
press(key)
release(key)
def write(string):
keyboard_api.write(string)