Ubuntu如何获取鼠标原始数据
欢迎使用Markdown编辑器
因任务需要,想获取鼠标的位置信息,python pyautogui包获取光标位置(x,y),但该方法受限于屏幕大小,当光标运动到屏幕边缘时,再往屏幕外拖动鼠标,无法获取鼠标变化信息,因此打算使用python usb包直接获取鼠标原始数据.
获取鼠标ID
获取所有USB口的ID信息,有十进制(Decimal)与十六进制(Hexadecimal)两种,获取Vendor ID与Product ID两个
#!/usr/bin/python
import sys
import usb.core
# find USB devices
dev = usb.core.find(find_all=True)
# loop through devices, printing vendor and product ids in decimal and hex
for cfg in dev:
sys.stdout.write('Decimal VendorID=' + str(cfg.idVendor) +