Find the "Human Interface Devices ID" attached to my computer.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Find the "Human Interface Devices ID" attached to my computer.

06 May 2021, 16:05

Dear members of the forum;

1- I want the Human interface devices connected to my computer to be listed in the Listbox.
2- I want the HID \ VID Serial number that I specified in the "My Device Insance Id" texbox in the Ahk Gui interface, if it is present in the listbox after searching the listbox, I want it to give the "result" texbox the warning that it is not available or not available.
3- I want to understand whether the device I have given the "device instance path" number is connected to the computer.

Note: I want this format (HID\VID_0483&PID_5741\7&30B9C82C&0&0000) to be listed in the Listbox in this way, neither more nor less.

I ask for your help and respect.

Code: Select all

Gui, Add, Edit, x162 y169 w290 h20 , HID\VID_0483&PID_5741\7&30B9C82C&0&0000
Gui, Add, ListBox, x32 y29 w420 h100 , ListBox
Gui, Add, Text, x32 y9 w180 h20 , HID\VID LİST
Gui, Add, Button, x312 y129 w140 h30 , Get Device Instance ID
Gui, Add, Text, x32 y169 w130 h20 , My Device Insance Id
Gui, Add, Button, x312 y229 w140 h30 , Find and Control
Gui, Add, Edit, x162 y199 w290 h20 , available / not available
Gui, Add, Text, x32 y199 w130 h20 , Result

Gui, Show, w479 h279, Find HID Device Instance ID
return

GuiClose:
ExitApp
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Find the "Human Interface Devices ID" attached to my computer.

07 May 2021, 00:43

Examples how to get the HID's:

Use these WMI functions and search for the DeviceID (Match on HID)

For (just) keyboards use -> Win32_Keyboard

Code: Select all

Win32_Keyboard()
{
	try
	{
		Keyboard := []
		for objItem in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_Keyboard")
		{
			Keyboard[A_Index, "Availability"] := objItem.Availability
			Keyboard[A_Index, "Caption"] := objItem.Caption
			Keyboard[A_Index, "ConfigManagerErrorCode"] := objItem.ConfigManagerErrorCode
			Keyboard[A_Index, "ConfigManagerUserConfig"] := objItem.ConfigManagerUserConfig
			Keyboard[A_Index, "CreationClassName"] := objItem.CreationClassName
			Keyboard[A_Index, "Description"] := objItem.Description
			Keyboard[A_Index, "DeviceID"] := objItem.DeviceID
			Keyboard[A_Index, "ErrorCleared"] := objItem.ErrorCleared
			Keyboard[A_Index, "ErrorDescription"] := objItem.ErrorDescription
			Keyboard[A_Index, "InstallDate"] := objItem.InstallDate
			Keyboard[A_Index, "IsLocked"] := objItem.IsLocked
			Keyboard[A_Index, "LastErrorCode"] := objItem.LastErrorCode
			Keyboard[A_Index, "Layout"] := objItem.Layout
			Keyboard[A_Index, "Name"] := objItem.Name
			Keyboard[A_Index, "NumberOfFunctionKeys"] := objItem.NumberOfFunctionKeys
			Keyboard[A_Index, "Password"] := objItem.Password
			Keyboard[A_Index, "PNPDeviceID"] := objItem.PNPDeviceID
			Keyboard[A_Index, "PowerManagementCapabilities"] := objItem.PowerManagementCapabilities[0]
			Keyboard[A_Index, "PowerManagementSupported"] := objItem.PowerManagementSupported
			Keyboard[A_Index, "Status"] := objItem.Status
			Keyboard[A_Index, "StatusInfo"] := objItem.StatusInfo
			Keyboard[A_Index, "SystemCreationClassName"] := objItem.SystemCreationClassName
			Keyboard[A_Index, "SystemName"] := objItem.SystemName
		}
		return Keyboard
	}
	return ""
}

For (just) input device use -> Win32_PointingDevice

Code: Select all

Win32_PointingDevice()
{
	try
	{
		PointingDevice := []
		for objItem in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_PointingDevice")
		{
			PointingDevice[A_Index, "Availability"] := objItem.Availability
			PointingDevice[A_Index, "Caption"] := objItem.Caption
			PointingDevice[A_Index, "ConfigManagerErrorCode"] := objItem.ConfigManagerErrorCode
			PointingDevice[A_Index, "ConfigManagerUserConfig"] := objItem.ConfigManagerUserConfig
			PointingDevice[A_Index, "CreationClassName"] := objItem.CreationClassName
			PointingDevice[A_Index, "Description"] := objItem.Description
			PointingDevice[A_Index, "DeviceID"] := objItem.DeviceID
			PointingDevice[A_Index, "DeviceInterface"] := objItem.DeviceInterface
			PointingDevice[A_Index, "DoubleSpeedThreshold"] := objItem.DoubleSpeedThreshold
			PointingDevice[A_Index, "ErrorCleared"] := objItem.ErrorCleared
			PointingDevice[A_Index, "ErrorDescription"] := objItem.ErrorDescription
			PointingDevice[A_Index, "Handedness"] := objItem.Handedness
			PointingDevice[A_Index, "HardwareType"] := objItem.HardwareType
			PointingDevice[A_Index, "InfFileName"] := objItem.InfFileName
			PointingDevice[A_Index, "InfSection"] := objItem.InfSection
			PointingDevice[A_Index, "InstallDate"] := objItem.InstallDate
			PointingDevice[A_Index, "IsLocked"] := objItem.IsLocked
			PointingDevice[A_Index, "LastErrorCode"] := objItem.LastErrorCode
			PointingDevice[A_Index, "Manufacturer"] := objItem.Manufacturer
			PointingDevice[A_Index, "Name"] := objItem.Name
			PointingDevice[A_Index, "NumberOfButtons"] := objItem.NumberOfButtons
			PointingDevice[A_Index, "PNPDeviceID"] := objItem.PNPDeviceID
			PointingDevice[A_Index, "PointingType"] := objItem.PointingType
			PointingDevice[A_Index, "PowerManagementCapabilities"] := objItem.PowerManagementCapabilities[0]
			PointingDevice[A_Index, "PowerManagementSupported"] := objItem.PowerManagementSupported
			PointingDevice[A_Index, "QuadSpeedThreshold"] := objItem.QuadSpeedThreshold
			PointingDevice[A_Index, "Resolution"] := objItem.Resolution
			PointingDevice[A_Index, "SampleRate"] := objItem.SampleRate
			PointingDevice[A_Index, "Status"] := objItem.Status
			PointingDevice[A_Index, "StatusInfo"] := objItem.StatusInfo
			PointingDevice[A_Index, "Synch"] := objItem.Synch
			PointingDevice[A_Index, "SystemCreationClassName"] := objItem.SystemCreationClassName
			PointingDevice[A_Index, "SystemName"] := objItem.SystemName
		}
		return PointingDevice
	}
	return ""
}

for all devices with installed drivers use -> Win32_PnPSignedDriver

Code: Select all

Win32_PnPSignedDriver()
{
	try
	{
		PnPSignedDriver := []
		for objItem in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_PnPSignedDriver")
		{
			PnPSignedDriver[A_Index, "ClassGuid"] := objItem.ClassGuid
			PnPSignedDriver[A_Index, "CompatID"] := objItem.CompatID
			PnPSignedDriver[A_Index, "Description"] := objItem.Description
			PnPSignedDriver[A_Index, "DeviceClass"] := objItem.DeviceClass
			PnPSignedDriver[A_Index, "DeviceID"] := objItem.DeviceID
			PnPSignedDriver[A_Index, "DeviceName"] := objItem.DeviceName
			PnPSignedDriver[A_Index, "DevLoader"] := objItem.DevLoader
			PnPSignedDriver[A_Index, "DriverDate"] := objItem.DriverDate
			PnPSignedDriver[A_Index, "DriverName"] := objItem.DriverName
			PnPSignedDriver[A_Index, "DriverVersion"] := objItem.DriverVersion
			PnPSignedDriver[A_Index, "FriendlyName"] := objItem.FriendlyName
			PnPSignedDriver[A_Index, "HardWareID"] := objItem.HardWareID
			PnPSignedDriver[A_Index, "InfName"] := objItem.InfName
			PnPSignedDriver[A_Index, "InstallDate"] := objItem.InstallDate
			PnPSignedDriver[A_Index, "IsSigned"] := objItem.IsSigned
			PnPSignedDriver[A_Index, "Location"] := objItem.Location
			PnPSignedDriver[A_Index, "Manufacturer"] := objItem.Manufacturer
			PnPSignedDriver[A_Index, "Name"] := objItem.Name
			PnPSignedDriver[A_Index, "PDO"] := objItem.PDO
			PnPSignedDriver[A_Index, "DriverProviderName"] := objItem.DriverProviderName
			PnPSignedDriver[A_Index, "Signer"] := objItem.Signer
			PnPSignedDriver[A_Index, "Started"] := objItem.Started
			PnPSignedDriver[A_Index, "StartMode"] := objItem.StartMode
			PnPSignedDriver[A_Index, "Status"] := objItem.Status
			PnPSignedDriver[A_Index, "SystemCreationClassName"] := objItem.SystemCreationClassName
			PnPSignedDriver[A_Index, "SystemName"] := objItem.SystemName
		}
		return PnPSignedDriver
	}
	return ""
}
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Re: Find the "Human Interface Devices ID" attached to my computer.

07 May 2021, 10:32

jNizM wrote:
07 May 2021, 00:43
Examples how to get the HID's:
Use these WMI functions and search for the DeviceID (Match on HID)
Firstly, thanks for your response. How can I integrate your codes in the listbox in gui? I do not have software knowledge that can do the listing and search and find buttons. Would you be interested? Thank you!
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Find the "Human Interface Devices ID" attached to my computer.

10 May 2021, 01:48

Small Example

Code: Select all

PnPSignedDriver := Win32_PnPSignedDriver()

Gui, Margin, 10, 10
Gui, Add, Edit, xm ym w800 hWndhEdt01 gSEARCH vEdt01
EM_SETCUEBANNER(hEdt01, "Search for HID\VID")
Gui, Add, ListView, xm y+10 w800 r20, % "Description|DeviceID"
for i, v in PnPSignedDriver
	if (InStr(PnPSignedDriver[i].DeviceID, "HID\VID_"))
		LV_Add("", PnPSignedDriver[i].Description, PnPSignedDriver[i].DeviceID)
LV_ModifyCol()
Gui, Show, AutoSize
return


; ===============================================================================================================================

GuiEscape:
GuiClose:
ExitApp


SEARCH:
	GuiControlGet, SearchField,, Edt01
	GuiControl, -Redraw, MainLV01
	LV_Delete()
	for i, v in PnPSignedDriver
		if (InStr(PnPSignedDriver[i].DeviceID, "HID\VID_")) && (InStr(PnPSignedDriver[i].DeviceID, SearchField))
			LV_Add("", PnPSignedDriver[i].Description, PnPSignedDriver[i].DeviceID)
	GuiControl, +Redraw, MainLV01
return


; ===============================================================================================================================

Win32_PnPSignedDriver()
{
	try
	{
		PnPSignedDriver := []
		for objItem in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_PnPSignedDriver")
		{
			PnPSignedDriver[A_Index, "Description"] := objItem.Description
			PnPSignedDriver[A_Index, "DeviceID"] := objItem.DeviceID
		}
		return PnPSignedDriver
	}
	return ""
}


EM_SETCUEBANNER(handle, string, option := true)
{
	static ECM_FIRST       := 0x1500 
	static EM_SETCUEBANNER := ECM_FIRST + 1
	if (DllCall("user32\SendMessage", "ptr", handle, "uint", EM_SETCUEBANNER, "int", option, "str", string, "int"))
		return true
	return false
}

; ===============================================================================================================================
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Re: Find the "Human Interface Devices ID" attached to my computer.

10 May 2021, 08:11

jNizM wrote:
10 May 2021, 01:48
Small Example
Dear jNizM..

Code: Select all

PnPSignedDriver := Win32_PnPSignedDriver()

Gui, Margin, 10, 10
Gui, Add, Edit, xm ym w550 hWndhEdt01 gSEARCH vEdt01
EM_SETCUEBANNER(hEdt01, "Search for HID\VID")

Gui, Add, ListView, Grid Multi +HScroll AltSubmit xm y+10 gLV w550 r20, % "Description|DeviceID"
for i, v in PnPSignedDriver
	if (InStr(PnPSignedDriver[i].DeviceID, "HID\VID_"))
		LV_Add("", PnPSignedDriver[i].Description, PnPSignedDriver[i].DeviceID)
		LV_ModifyCol()
Gui, Add, Text, xm ym+415 w100, HID\VID
Gui, Add, Edit, xm ym+430 w550 hWndhEdt02 vEdt02
EM_SETCUEBANNER(hEdt02, "Listview Clicked Item HID\VID")
Gui, Add, Button, xm ym+460 w100, HID\VID Kopyala 

Gui, Show, AutoSize
return


; ===============================================================================================================================

GuiEscape:
GuiClose:
ExitApp


SEARCH:
Gui, Submit, NoHide
	GuiControlGet, SearchField,, Edt01
	GuiControl, -Redraw, MainLV01
	LV_Delete()
	for i, v in PnPSignedDriver
		if (InStr(PnPSignedDriver[i].DeviceID, "HID\VID_")) && (InStr(PnPSignedDriver[i].DeviceID, SearchField))
			LV_Add("", PnPSignedDriver[i].Description, PnPSignedDriver[i].DeviceID)
	GuiControl, +Redraw, MainLV01
	
	       

return

LV:
Gui, Submit, NoHide
	 RowNumber := LV_GetNext()
     LV_GetText(Edt02, RowNumber, 2)
	 GuiControl,, Edt02, %Edt02%  
return

; ===============================================================================================================================


; ===============================================================================================================================

Win32_PnPSignedDriver()
{
	try
	{
		PnPSignedDriver := []
		for objItem in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_PnPSignedDriver")
		{
			PnPSignedDriver[A_Index, "Description"] := objItem.Description
			PnPSignedDriver[A_Index, "DeviceID"] := objItem.DeviceID
		}
		return PnPSignedDriver
	}
	return ""
}


EM_SETCUEBANNER(handle, string, option := true)
{
	static ECM_FIRST       := 0x1500 
	static EM_SETCUEBANNER := ECM_FIRST + 1
	if (DllCall("user32\SendMessage", "ptr", handle, "uint", EM_SETCUEBANNER, "int", option, "str", string, "int"))
		return true
	return false
}
I am sharing the final version of the code adapted for myself.
I will have one last request from you.
We were able to list an existing HID \ VID device in the list, if it is attached to the computer. Now I want to do something like this.

ExampleHIDVID:= "HID\VID_0C2E&PID_0CA1&MI_01\7&1E316D0D&0&0000"

Let's assume that there is an "exampleHIDVID" number in an editbox. Write me such a code that this code; Check the written HIDVID number in the editbox, that is, whether it is plugged into the computer or not, and if it is, open the gui. If it's not plugged in, don't let it open the gui.

as a result.
The HIDVID code I have set in the editbox:
"HID\VID_0C2E&PID_0CA1&MI_01\7&1E316D0D&0&0000" will check if it is connected to the computer and show the gui. If it is not, msgbox will "The device you specified is not connected. So you cannot open the gui!" I want it to give a warning like.

Note: (You can also try the HIDVID code I gave as an example from the HIDVID code of a device connected to your computer.)

Thank you..
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Re: Find the "Human Interface Devices ID" attached to my computer.

10 May 2021, 18:06

jNizM wrote:
10 May 2021, 01:48
Small Example
Also, when I disconnect my barcode device from the computer, the HID \ VID is listed again. How can I check if the device is plugged in?
iPhilip
Posts: 796
Joined: 02 Oct 2013, 12:21

Re: Find the "Human Interface Devices ID" attached to my computer.

10 May 2021, 20:34

You might check its status:

Code: Select all

PnPSignedDriver[A_Index, "Status"] := objItem.Status
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Re: Find the "Human Interface Devices ID" attached to my computer.

10 May 2021, 21:36

iPhilip wrote:
10 May 2021, 20:34
You might check its status:

Code: Select all

PnPSignedDriver[A_Index, "Status"] := objItem.Status
It didn't work in Status. I plug the barcode device into the computer, it sees the device. but after removing the barcode device, when I refresh the list, I see it is still in the list. It disappears when I refresh the list again after 5 minutes. Why is that ?? Normally, when a USB device is plugged into the computer, the system detects and installs its hardware. When you disconnect the usb device, there is instant hardware change .. Why am I facing such a problem? how can i solve it?

My main purpose is that if the program I wrote detects the device whose HID / VID number is defined, it will allow the program to open. that is, the GUI will open. If a different device is plugged in, the program will not work if the HIDVID number is different. so it won't open gui. the purpose is to determine if the barcode device is installed and if the hıdvid number matches. To allow or not to open the gui accordingly.


this is the final code. I ask for your help. :shock:

Code: Select all

PnPSignedDriver := Win32_PnPSignedDriver()

Gui, Margin, 10, 10
Gui, Add, Edit, xm ym w550 hWndhEdt01 gSEARCH vEdt01
EM_SETCUEBANNER(hEdt01, "Search for HID\VID")

;~ Gui, Add, ListView, Grid Multi +HScroll AltSubmit xm y+10 gLV w550 h250 r20, % "Description|DeviceID|ClassGuid|CompatID|DeviceClass|DeviceName|DevLoader|DriverDate|DriverName|DriverVersion|FriendlyName|HardWareID|InfName|InstallDate|IsSigned|Location|Manufacturer|Name|PDO|DriverProviderName|Signer|Started|StartMode|Status|SystemCreationClassName|SystemName"

Gui, Add, ListView, Grid Multi +HScroll AltSubmit xm y+10 gLV w550 h250 r20, % "Description|DeviceID|Status"

	;~ if (InStr(PnPSignedDriver[i].DeviceID, "HID\VID_0C2E&PID_1001&MI_01\8&1448ADA3&0&0000"))
;HID\VID_0483&PID_5741\7&30B9C82C&0&0000
		
		for i, v in PnPSignedDriver
		if (InStr(PnPSignedDriver[i].DeviceID, "HID\VID_"))
		LV_Add("", PnPSignedDriver[i].Description, PnPSignedDriver[i].DeviceID, PnPSignedDriver[i].Status)
		LV_ModifyCol()
		;~ LV_Add("", PnPSignedDriver[i].Description, PnPSignedDriver[i].DeviceID, PnPSignedDriver[i].ClassGuid, PnPSignedDriver[i].CompatID, PnPSignedDriver[i].DeviceClass, PnPSignedDriver[i].DeviceName, PnPSignedDriver[i].DevLoader, PnPSignedDriver[i].DriverDate, PnPSignedDriver[i].DriverName, PnPSignedDriver[i].DriverVersion, PnPSignedDriver[i].FriendlyName, PnPSignedDriver[i].HardWareID, PnPSignedDriver[i].InfName, PnPSignedDriver[i].InstallDate, PnPSignedDriver[i].IsSigned, PnPSignedDriver[i].Location, PnPSignedDriver[i].Manufacturer, PnPSignedDriver[i].Name, PnPSignedDriver[i].PDO, PnPSignedDriver[i].DriverProviderName, PnPSignedDriver[i].Signer, PnPSignedDriver[i].Started, PnPSignedDriver[i].StartMode, PnPSignedDriver[i].Status, PnPSignedDriver[i].SystemCreationClassName, PnPSignedDriver[i].SystemName)
		;~ LV_ModifyCol()
			
Gui, Add, Text, xm ym+285 w100, HID\VID
Gui, Add, Edit, xm ym+300 w550 hWndhEdt02 vEdt02
EM_SETCUEBANNER(hEdt02, "Listview Clicked Item HID\VID")
Gui, Add, Button, xm ym+330 w100 gHIDVIDKopyala, HID\VID Kopyala 
Gui, Add, Button, xm+110 ym+330 w100 gYenile, Yenile
Gui, Add, Button, xm+220 ym+330 w100 gKontrolEt, Kontrol Et

Gui, Show, AutoSize
return

; ===============================================================================================================================

GuiEscape:
GuiClose:
ExitApp

Esc::
Yenile:
Reload
return

KontrolEt:
for i, v in PnPSignedDriver
	if (InStr(PnPSignedDriver[i].DeviceID, "HID\VID_0C2E&PID_1001&MI_01\8&1448ADA3&0&0000"))
	{	MsgBox, Cihaz bulundu
		;~ 
	}
return

HIDVIDKopyala:
clipboard := ""
clipboard := % Edt02
MsgBox, HID\VID Kopyalandı!
return

SEARCH:
Gui, Submit, NoHide
	GuiControlGet, SearchField,, Edt01
	GuiControl, -Redraw, MainLV01
	LV_Delete()
	for i, v in PnPSignedDriver
		if (InStr(PnPSignedDriver[i].DeviceID, "HID\VID_")) && (InStr(PnPSignedDriver[i].DeviceID, SearchField))
			LV_Add("", PnPSignedDriver[i].Description, PnPSignedDriver[i].DeviceID, PnPSignedDriver[i].Status)
		
		;~ LV_Add("", PnPSignedDriver[i].Description, PnPSignedDriver[i].DeviceID, PnPSignedDriver[i].ClassGuid, PnPSignedDriver[i].CompatID, PnPSignedDriver[i].DeviceClass, PnPSignedDriver[i].DeviceName, PnPSignedDriver[i].DevLoader, PnPSignedDriver[i].DriverDate, PnPSignedDriver[i].DriverName, PnPSignedDriver[i].DriverVersion, PnPSignedDriver[i].FriendlyName, PnPSignedDriver[i].HardWareID, PnPSignedDriver[i].InfName, PnPSignedDriver[i].InstallDate, PnPSignedDriver[i].IsSigned, PnPSignedDriver[i].Location, PnPSignedDriver[i].Manufacturer, PnPSignedDriver[i].Name, PnPSignedDriver[i].PDO, PnPSignedDriver[i].DriverProviderName, PnPSignedDriver[i].Signer, PnPSignedDriver[i].Started, PnPSignedDriver[i].StartMode, PnPSignedDriver[i].Status, PnPSignedDriver[i].SystemCreationClassName, PnPSignedDriver[i].SystemName)
	GuiControl, +Redraw, MainLV01
return


LV:
Gui, Submit, NoHide
	 RowNumber := LV_GetNext()
     LV_GetText(Edt02, RowNumber, 2)
	 GuiControl,, Edt02, %Edt02%  
return

; ===============================================================================================================================


; ===============================================================================================================================

Win32_PnPSignedDriver()
{
	try
	{
		PnPSignedDriver := []
		for objItem in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_PnPSignedDriver")
		{
			
			PnPSignedDriver[A_Index, "Description"] := objItem.Description
			PnPSignedDriver[A_Index, "DeviceID"] := objItem.DeviceID
			;~ PnPSignedDriver[A_Index, "ClassGuid"] := objItem.ClassGuid
			;~ PnPSignedDriver[A_Index, "CompatID"] := objItem.CompatID
			;~ PnPSignedDriver[A_Index, "DeviceClass"] := objItem.DeviceClass
			;~ PnPSignedDriver[A_Index, "DeviceName"] := objItem.DeviceName
			;~ PnPSignedDriver[A_Index, "DevLoader"] := objItem.DevLoader
			;~ PnPSignedDriver[A_Index, "DriverDate"] := objItem.DriverDate
			;~ PnPSignedDriver[A_Index, "DriverName"] := objItem.DriverName
			;~ PnPSignedDriver[A_Index, "DriverVersion"] := objItem.DriverVersion
			;~ PnPSignedDriver[A_Index, "FriendlyName"] := objItem.FriendlyName
			;~ PnPSignedDriver[A_Index, "HardWareID"] := objItem.HardWareID
			;~ PnPSignedDriver[A_Index, "InfName"] := objItem.InfName
			;~ PnPSignedDriver[A_Index, "InstallDate"] := objItem.InstallDate
			;~ PnPSignedDriver[A_Index, "IsSigned"] := objItem.IsSigned
			;~ PnPSignedDriver[A_Index, "Location"] := objItem.Location
			;~ PnPSignedDriver[A_Index, "Manufacturer"] := objItem.Manufacturer
			;~ PnPSignedDriver[A_Index, "Name"] := objItem.Name
			;~ PnPSignedDriver[A_Index, "PDO"] := objItem.PDO
			;~ PnPSignedDriver[A_Index, "DriverProviderName"] := objItem.DriverProviderName
			;~ PnPSignedDriver[A_Index, "Signer"] := objItem.Signer
			;~ PnPSignedDriver[A_Index, "Started"] := objItem.Started
			;~ PnPSignedDriver[A_Index, "StartMode"] := objItem.StartMode
			PnPSignedDriver[A_Index, "Status"] := objItem.Status
			;~ PnPSignedDriver[A_Index, "SystemCreationClassName"] := objItem.SystemCreationClassName
			;~ PnPSignedDriver[A_Index, "SystemName"] := objItem.SystemName
			
		}
		return PnPSignedDriver
	}
	return ""
}


EM_SETCUEBANNER(handle, string, option := true)
{
	static ECM_FIRST       := 0x1500 
	static EM_SETCUEBANNER := ECM_FIRST + 1
	if (DllCall("user32\SendMessage", "ptr", handle, "uint", EM_SETCUEBANNER, "int", option, "str", string, "int"))
		return true
	return false
}
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Re: Find the "Human Interface Devices ID" attached to my computer.

10 May 2021, 21:45

Can the "Win32_PnPEntity" function be used instead of "Win32_PnPSignedDriver"?
If it is available, can you write the script of the function?
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Find the "Human Interface Devices ID" attached to my computer.

11 May 2021, 02:00

Not possible with Win32_PnPEntity.
For more you need some DllCall's. (maybe GetRawInputDeviceList / GetRawInputDeviceInfo)
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
iPhilip
Posts: 796
Joined: 02 Oct 2013, 12:21

Re: Find the "Human Interface Devices ID" attached to my computer.

11 May 2021, 17:04

chngrcn wrote:
10 May 2021, 21:36
It didn't work in Status. I plug the barcode device into the computer, it sees the device. but after removing the barcode device, when I refresh the list, I see it is still in the list. It disappears when I refresh the list again after 5 minutes. Why is that ?? Normally, when a USB device is plugged into the computer, the system detects and installs its hardware. When you disconnect the usb device, there is instant hardware change .. Why am I facing such a problem? how can i solve it?
You might want to take a look at @jNizM's code to detect a USB device (link). While I don't think you can get the HID from the various DEV_BROADCAST structures, you can detect if the device is plugged in or not.

I hope this helps.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Re: Find the "Human Interface Devices ID" attached to my computer.

12 May 2021, 03:30

jNizM wrote:
11 May 2021, 02:00
Not possible with Win32_PnPEntity.
For more you need some DllCall's. (maybe GetRawInputDeviceList / GetRawInputDeviceInfo)
Let me ask you my question more clearly ..

I have a barcode device. HID\VID number "HID\VID_0C2E&PID_0CA1&MI_01\7&1E316D0D&0&0000" this.
If this device is plugged into the computer, let it open the GUI.
If it is not plugged in, do not allow gui to open.

That is, it will detect the HID\VID number I have defined, the HID\VID number of the barcode device to be installed on the computer and allow the gui to open. If HID\VID does not match it will not allow gui to open.

Note: (different barcode devices will be used .. my aim is to prevent the use of a pirated program. The program that can run from the HID\VID number of the device I have specified. I have another barcode device plugged in, let it not let the program run. I mean, never open the gui..)
XMCQCX
Posts: 224
Joined: 14 Oct 2020, 23:44

Re: Find the "Human Interface Devices ID" attached to my computer.

13 May 2021, 22:02

Deleted
Last edited by XMCQCX on 09 Sep 2022, 20:30, edited 1 time in total.
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Re: Find the "Human Interface Devices ID" attached to my computer.

14 May 2021, 17:23

XMCQCX wrote:
13 May 2021, 22:02
This script will detect when "HID\VID_0C2E&PID_0CA1&MI_01\7&1E316D0D&0&0000" is connected.
Unfortunately it didn't work. I added the following to the messaging part of the code you sent to see if the scenario is on alert and I tried it ... it didn't work .. When I plug the device into the USB port and remove it, it detects it .. but it can't detect the device.

Code: Select all

If Dev1 = %Device1%
{
MsgBox, %Device1% is connected
}
else
{
	MsgBox, %Device1% is NOTconnected
}

FormatTime, var3, YYYYMMDDHH24MISS, yyyyMMddHHmmss
Clipboard = %var3%

}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: gongnl, marypoppins_1 and 116 guests