小编qlt*_*qlt的帖子

Pywinusb:处理来自多个键盘的事件

我正在尝试处理来自多个 USB 键盘的事件,以便代码知道输入来自哪个键盘。该代码通过设备实例 ID 识别不同的键盘(它们都具有相同的产品和供应商 ID),但不识别用户输入的来源(它只是在它们之间切换)。

这对于 pywinusb 来说是可能的吗?我尝试使用事件处理程序但没有运气。

from time import sleep
from msvcrt import kbhit

import pywinusb.hid as hid

# feel free to test
target_vendor_id = 0xffff
target_product_id = 0x0035

def sample_handler(data):
    print("Raw data: {0}".format(data))

def getinput(data, id):
    print data
    print id
    if(id == "8&2754010&0&0000" and data == "09008708"):
        print "Success"
    else:
        print "Failed"

def raw_test():

   # example, handle the HidDeviceFilter().get_devices() result grouping items by parent ID
   all_hids = hid.HidDeviceFilter(vendor_id = target_vendor_id, product_id = target_product_id).get_devices()
   #print all_hids
   if …
Run Code Online (Sandbox Code Playgroud)

python pywinusb

5
推荐指数
1
解决办法
758
查看次数

标签 统计

python ×1

pywinusb ×1