1

Using the Python HookManager, is it possible to get some distinction as to which device is giving me the input? Like if I had two keyboards, or a QR scanner for instance? How could I find out where the input is coming from?

import pyHook
import pythoncom

chars = ""
def pressed_chars(event):
    global chars
    if event.Ascii:
        char = chr(event.Ascii)
        if event.Ascii == 3:
            quit()
        else:
            chars += char
            print chars

proc = pyHook.HookManager()
proc.KeyDown = pressed_chars
proc.HookKeyboard()
pythoncom.PumpMessages()

The code above simply uses HookManager to detect keyboard input. But I can't find anything in the event variable that tells me where the input came from?

Chud37
  • 4,907
  • 13
  • 64
  • 116

0 Answers0