How can I retrieve the items plugged into the computer through USB using python? I've searched around on here and found some old examples which don't appear to work anymore as they are over 5 years old.
I would like an example where I can list the names seen in the image below which is a screenshot of the Device Manager.
The code below lists all the USB devices but none of the data returns the Names seen in the image, why is that?
import win32com.client
import pprintwmi = win32com.client.GetObject ("winmgmts:")
for usb in wmi.InstancesOf ("Win32_USBHub"):# print usb.DeviceID# pprint.pprint (dir(usb))# pprint.pprint (vars(usb))# print usb.__dict__print ('Device ID:', usb.DeviceID)print ('Name:', usb.name)print ('System Name:', usb.SystemName)print ('Caption:', usb.Caption)print ('Caption:', usb.Caption)print ('ClassCode:', usb.ClassCode)print ('CreationClassName:', usb.CreationClassName)print ('CurrentConfigValue:', usb.CurrentConfigValue)print ('Description:', usb.Description)print ('PNPDeviceID:', usb.PNPDeviceID)print ('Status:', usb.Status)print ('\n')