简体   繁体   中英

windows system wide keyboard input emulation in python

I'm sending keyboard signals to the OS (Windows) via python. The problem is the specific application (Project 64, Nintendo 64 emulator) is not receiving the signals, I'm not sure why. The keys are registered in Word and my browser for example.

shell = win32com.client.Dispatch("WScript.Shell")


ser=serial.Serial('com10',115200)

while 1:
    datain=ser.read(1)
    if datain=='':
        continue
    datain_int=int(binascii.hexlify(datain), 16)
    datain_bin=bin(datain_int)
    if datain_int==0:
        continue
    print(datain_int)
    if datain_int==128:
        shell.SendKeys("a")

Since other applications are receiving your keystrokes it is entirely possible that the application, being an emulator, is scanning the keyboard directly rather than having keystrokes passed from the operating system.

If this is the case you would probably be better off downloading the source code and patching it to use input from the serial port directly. You an also have a look at the source code to see how it is receiving the keyboard events.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM