-
Notifications
You must be signed in to change notification settings - Fork 2
/
ges.py
31 lines (21 loc) · 1.73 KB
/
ges.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
import serial # add Serial library for serial communication
import pyautogui # add pyautogui library for programmatically controlling the mouse and keyboard.
Arduino_Serial = serial.Serial('com3',9600) # Initialize serial and Create Serial port object called Arduino_Serial
while 1:
incoming_data = str (Arduino_Serial.readline()) # read the serial data and print it as line
print (incoming_data) # print the incoming Serial data
if 'next' in incoming_data: # if incoming data is 'next'
pyautogui.hotkey('ctrl', 'pgdn') # perform "ctrl+pgdn" operation which moves to the next tab
if 'previous' in incoming_data: # if incoming data is 'previous'
pyautogui.hotkey('ctrl', 'pgup') # perform "ctrl+pgup" operation which moves to the previous tab
if 'down' in incoming_data: # if incoming data is 'down'
#pyautogui.press('down') # performs "down arrow" operation which scrolls down the page
pyautogui.scroll(-100)
if 'up' in incoming_data: # if incoming data is 'up'
#pyautogui.press('up') # performs "up arrow" operation which scrolls up the page
pyautogui.scroll(100)
if 'change' in incoming_data: # if incoming data is 'change'
pyautogui.keyDown('alt') # performs "alt+tab" operation which switches the tab
pyautogui.press('tab')
pyautogui.keyUp('alt')
incoming_data = ""; # clears the data