Friday, 15 April 2011

Read HID input while window is "out of focus" in Python -



Read HID input while window is "out of focus" in Python -

i'm struggling issue days , can't working. i've started python , i'm facing biggest problem face in project.

here's situation: have create programme scans barcode. communicates online service , prints pdf. works fine, want scan barcode when window "out of focus". want allow people scan barcode scanner while have window minimized.

i'm running windows 8 , i'm working python 3.3. barcode scanner hid device , presents keyboard. tried convert project python 3.3, not work. --> http://learn.adafruit.com/barcode-scanner/overview end kinds of errors, still not completly understand.

today tried utilize pywinusb, module seems have issues regarding finding hid device because can't find keyboard , mouse.

maybe it's complicated question, has expirience , knows how working.

if barcode scanner presents keyboard, isn't want key logger runs in background? searching it, this among first google results "python keylogger" - according source, needs pywin32 , pyhook. removed logging cut down code sample minimum, set handling code inonkeyboardevent. tested , works python 2.7 installation on windows 7, modules should compatible python 3.3.

import pythoncom, pyhook, sys def onkeyboardevent(event): print "key: ", chr(event.ascii) logging.log(10,chr(event.ascii)) homecoming true hm = pyhook.hookmanager() hm.keydown = onkeyboardevent hm.hookkeyboard() pythoncom.pumpmessages()

python windows barcode-scanner hid

No comments:

Post a Comment