-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapmess.py
79 lines (72 loc) · 2.34 KB
/
capmess.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import random
import string
import os,sys,time
print('''
*-------------*
####CAPmESs####
*-------------*
''')
#-----PARAMETERS-----
chance = 0.5 #how much chance there is that the letter will be lower case
#--------------------
def on_press(k):
global pressing,chance,os,dev,keyboard
try:
if os == 'windows':
if GetKeyState(VK_CAPITAL) > 0 and k.char in string.ascii_lowercase:
if random.random() < chance:
pressing.append(True)
keyboard.tap(Key.backspace)
keyboard.press(Key.shift)
keyboard.tap(k.char)
keyboard.release(Key.shift)
elif os == 'linux':
if 1 in dev.leds() and k.char in string.ascii_lowercase:
if random.random() < chance:
pressing.append(True)
time.sleep(0.1)
keyboard.tap(Key.backspace)
keyboard.press(Key.shift)
keyboard.tap(k)
keyboard.release(Key.shift)
except:
pass
def on_release(k):
global pressing,os
try:
if os == "windows":
if len(pressing)!=0 and k.char in string.ascii_lowercase:
pressing.pop(0)
elif os == "linux":
if len(pressing)!=0 and k.char in string.ascii_lowercase:
pressing.pop(0)
except:
pass
pressing=[]
os = None
#Check if os is linux or windows
if sys.platform == 'win32':
print('Windows detected')
os = 'windows'
from win32api import GetKeyState
from win32con import VK_CAPITAL
from pynput.keyboard import Key, Listener, Controller
keyboard = Controller()
# Collect events until released
with Listener(
on_press=on_press,on_release=on_release) as listener:
listener.join()
elif sys.platform == 'linux':
print('Linux detected')
os = 'linux'
from pynput.keyboard import Key, Listener, Controller
from evdev import InputDevice, categorize, ecodes
dev = InputDevice('/dev/input/event3')
keyboard = Controller()
with Listener(
on_press=on_press,on_release=on_release) as listener:
listener.join()
else:
os = 'mac'
print('MacOS is not supported')
exit()