My eventual goal is to detect if a usb keyboard is unplugged - it has to work on mac, windows and linux, which is why I went for python. (basically I have a switching usb hub, like a kvm - but only the usb - and I want to do certain things like shut off the screen when you switch away from a box; I have mac, windows and linux boxes on the switch).
I saw the pyusb and thought, ok - I'll use that to poll usb devices every 30s or so. so
I started with windows - did the following
pip install pyusb
pip install libusb
copy C:\python39\lib\sitepackages\libusb\_platform_windows\x64\libusb-1.0.dll C:\python39\scripts
and then tried the following script in jupyter
import usb
for bus in usb.busses():
for device in bus.devices():
print( "Device: " + device.filename )
and it just dies on the first line with "entity not found".
any idea how to fix this?
Or otherwise how to get an event when a usb keyboard (or other device) is disconnected?