Advertisement
MattRobinson

Untitled

Feb 9th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import pywinusb.hid as hid
  2. from time import sleep
  3. import re
  4. import linecache
  5.  
  6. vendor_id = 0x6688
  7. product_id = 0x6850
  8.  
  9. devices = hid.HidDeviceFilter(vendor_id=vendor_id, product_id=product_id).get_devices()
  10.  
  11. def sample_handler(data):
  12. for i in data:
  13. if data[9]!=0:
  14. print(data[9])
  15. return
  16.  
  17.  
  18. if devices:
  19. device = devices[0]
  20.  
  21. device.open()
  22. device.set_raw_data_handler(sample_handler)
  23. print("------------")
  24. while device.is_plugged():
  25. # just keep the device opened to receive events
  26. sleep(0.5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement