modifier code pour afficher le device id des claviers
Bonjour,
En partant de ce code (ou autre), est il possible de scanner que les concentrateur hub et les claviers, tout le reste ne m'est pas utile et prend du temps 15'' sur mon PC.
Ce sera utilisé avec Excel 2010/32bits et win10
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Sub usb_1()
strComputer = "."
[A1:B1048576].ClearContents
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colDevices = objWMIService.ExecQuery _
("Select * From Win32_USBControllerDevice")
i = 1
For Each objDevice In colDevices
strDeviceName = objDevice.Dependent
strQuotes = Chr(34)
strDeviceName = Replace(strDeviceName, strQuotes, "")
arrDeviceNames = Split(strDeviceName, "=")
strDeviceName = arrDeviceNames(1)
Set colUSBDevices = objWMIService.ExecQuery _
("Select * From Win32_PnPEntity Where DeviceID = '" & strDeviceName & "'")
For Each objUSBDevice In colUSBDevices
' WScript.Echo objUSBDevice.Description
' WScript.Echo objUSBDevice.PnPDeviceID ' Changed from Description to PnPDeviceID
'as this script can be altered to return any property
'of the Win32_USBControllerDevice collection.
Range(Cells(i, 1), Cells(i, 1)) = objUSBDevice.Description
Range(Cells(i, 2), Cells(i, 2)) = objUSBDevice.PNPDeviceID
i = i + 1
Next
Next
End Sub |
Voici ce que je voudrais seulement :
Concentrateur USB générique...........USB\VID_05E3&PID_0608\5&2A2B26F7&0&2...............'=>hub
Concentrateur USB générique..........USB\VID_05E3&PID_0608\6&2E00BB6&0&4.....................'=>hub
Périphérique d’entrée USB...............USB\VID_413C&PID_2106\7&22592B1F&0&3...................'=>clavier 1
Périphérique clavier PIH..................HID\VID_413C&PID_2106\8&3663B53&0&0000...............'=>clavier 1
Périphérique d’entrée USB...............USB\VID_413C&PID_2105\6&2E00BB6&0&2....................'=>clavier 2
Périphérique clavier PIH...................HID\VID_413C&PID_2105\7&AF77C65&0&0000..............'=>clavier 2
Merci
Bonne journée