-
Notifications
You must be signed in to change notification settings - Fork 0
/
ei_project.py
78 lines (56 loc) · 2 KB
/
ei_project.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
import serial #Serial imported for Serial communication
import time #Required to use delay functions
import pyautogui
ArduinoSerial = serial.Serial('/dev/ttyACM1',9600) #Create Serial port object called arduinoSerialData
time.sleep(2) #wait for 2 seconds for the communication to get established
while 1:
incoming = str (ArduinoSerial.readline()) #read the serial data and print it as line
print incoming
if 'play' in incoming:
pyautogui.typewrite(['space'], 0.2)
elif 'pause' in incoming:
pyautogui.typewrite(['space'], 0.2)
elif 'rewind' in incoming:
pyautogui.hotkey('ctrl', 'left')
elif 'close' in incoming:
pyautogui.hotkey('alt', 'f4')
elif 'forward' in incoming:
a=incoming.split(" ")
print a
if len(a)>2:
if "minute" or "minutes" in a:
for i in range(int(a[2])):
print a[2]
pyautogui.hotkey('ctrl', 'right')
time.sleep(1)
else:
pyautogui.hotkey('ctrl', 'right')
elif 'volume down' in incoming:
for i in range(4):
pyautogui.hotkey('ctrl', 'down')
#pyautogui.hotkey('ctrl', 'down')
elif 'mute' in incoming:
pyautogui.hotkey('m')
elif 'volume up' in incoming:
for i in range(4):
pyautogui.hotkey('ctrl', 'up')
#pyautogui.hotkey('ctrl', 'up')
elif 'delete all' in incoming:
pyautogui.hotkey('ctrl', 'a')
pyautogui.typewrite(['space'], 0.2)
elif 'unmute' in incoming:
pyautogui.hotkey('m')
elif 'take screenshot' in incoming:
pyautogui.hotkey('prtsc')
time.sleep(2)
pyautogui.hotkey('enter')
elif 'open edit' in incoming:
pyautogui.click(x=30,y=100,clicks=2)
elif 'switch window' in incoming:
pyautogui.hotkey('alt','tab')
elif 'open terminal' in incoming:
pyautogui.hotkey('ctrl','alt','t')
elif len(incoming)>15:
pyautogui.click(x=85,y=118)
pyautogui.typewrite(incoming)
incoming = "";