-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (39 loc) · 1.19 KB
/
main.py
File metadata and controls
51 lines (39 loc) · 1.19 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
# Virtual Mouse
# Created by Sunny Y.
#
# Program designed to replace mouse control with a camera.
#
# Installation Setup in README.md
from virtual_mouse import VirtualMouse
from pynput import keyboard
m1 = VirtualMouse()
def on_press(key):
try:
#print('alphanumeric key {0} pressed'.format(key.char))
if key.char == '1': # toggles pauses the program
m1.mouseRunning = not m1.mouseRunning
elif key.char == '2':
m1.drawLabels = not m1.drawLabels
elif key.char == '3':
m1.drawConnections = not m1.drawConnections
elif key.char == '4':
m1.halfScreen = not m1.halfScreen
m1.setBound()
elif key.char == '5':
m1.showHud = not m1.showHud
elif key.char == '6':
m1.hideCam = not m1.hideCam
except AttributeError:
print('special key {0} pressed'.format(key))
def on_release(key):
print('{0} released'.format(key))
if key == keyboard.Key.tab: # stops the program
m1.open = False
listener = keyboard.Listener(
on_press=on_press,
on_release=on_release)
listener.start()
def main():
while m1.open:
m1.draw()
main()