import serial
import win32com.client

shell = win32com.client.Dispatch("WScript.Shell")

ser = serial.Serial()
ser.baudrate = 9600
ser.port = 'COM8'
ser.parity = serial.PARITY_NONE
ser.stopbits = serial.STOPBITS_ONE
ser.xonxoff = 0

print(ser)
ser.open()

while True:
	line = ser.readline().rstrip().replace('\x00', '').replace('\r','')
	data = line.split(' ')
	if data[0] == 's':
		shell.SendKeys(' ')
	if data[0] == 'k':
		if data[1] == ';' or data[1] == '/':
			shell.SendKeys('{BS}')
		else:
			shell.SendKeys(data[1])
	if data[0] == 'c':
		print("Please type: {0}".format(data[1]))
	if data[0] == 'd':
		print("\t{0}".format(data[1:]))

# Try typing, "the quick, brown fox jumps over the lazy dog."