keyboard emulation with windows and python -


i'm trying achieve same under windows have achieved in linux environment. serial keyboard input, please or point me in right direction. i'd should simple possible, tried failed.

import serial import time import uinput import binascii  ser = serial.serial(     port='/dev/ttyusb0',\     baudrate=115200,\     parity=serial.parity_none,\     stopbits=serial.stopbits_one,\     bytesize=serial.eightbits,\     timeout=0)  ser.open()  device = uinput.device([uinput.key_a, uinput.key_b])  time.sleep(1) while true:     datain=ser.read(1)     if datain=='':         continue     datain_int=int(binascii.hexlify(datain), 16)     datain_bin=bin(datain_int)     if datain_int==0:         continue     if datain_int==128:         device.emit_click(uinput.key_a)     elif datain_int==64:         device.emit_click(uinput.key_b) 

i'm not sure you're trying exactly, here's script once wrote build hotkey cheat engine gta san andreas

import pyhook import pythoncom import win32com.client shell = win32com.client.dispatch("wscript.shell") hm = pyhook.hookmanager() def onkeyboardevent(event):     if event.keyid == 48:         #cheat set 1         shell.sendkeys("chttychttybangbang")     if event.keyid == 49:         #cheat set 2         shell.sendkeys("hesoyamuzumymwfullclip")     if event.keyid == 50:         #cheat set 3         shell.sendkeys("hesoyaprofessionalskitfullclip")     if event.keyid == 51:         #cheat set 4         shell.sendkeys("hesoyalxgiwylfullclip")     if event.keyid == 52:         #cheat set 5         shell.sendkeys("zeiivgylteiczflyingfisheveryoneisrichspeedfreak")     if event.keyid == 53:         #cheat set 6         shell.sendkeys("aiwprton")     if event.keyid == 54:         #cheat set 7         shell.sendkeys("oldspeeddemon")     if event.keyid == 55:         #cheat set 8         shell.sendkeys("itsallbull")     if event.keyid == 56:         #cheat set 9         shell.sendkeys("monstermash")     if event.keyid == 57:         #cheat set 10         shell.sendkeys("jumpjetkgggdkpaiypwzqpohdudeflyingtostunt")     # return true pass event other handlers     return true hm.keydown = onkeyboardevent hm.hookkeyboard() pythoncom.pumpmessages() 

and worked on windows. hope helps


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -