Haven't played much with Jim's AV Extender, but was doing some old-school prep work with WMI. With Win10/11 decided to explore with the Win32_PnPEntity class [I got nothing from Win32_VideoController]. Most of what I read suggested selecting with Name like "%%camera%%", but even though I checked for my Webcam on Win10, nothing came up. However, the script below did work, [and I did read there could be fluctuations with how to find a camera per manufacturer/model]. Anyway, just wondering if anyone using the script could find their camera or adjust the code accordingly
;Winbatch 2024 - find my camera
;it is WMI so should work with earlier versions
strComputer = "."
oWMI = GetObject( "winmgmts:\\" : strComputer : "\root\cimv2")
WQL = "SELECT * FROM Win32_PnPEntity WHERE Service like '%%usbvideo%%'"
oP= oWMI.ExecQuery(WQL)
ForEach p in oP
svc = p.Service
caption = p.Caption
id = p.PNPDeviceID
Name= p.Name
Message("Camera",svc:@LF:caption:@LF:id:@LF:Name)
Next
oP=0
oWMI=0
Exit
This works for me using Name. Obviously, if you don't have a Logitec Camera you probably won't get anything.
Jim
; Winbatch - Search for device by name using WMI
strComputer = "."
oWMI = GetObject("winmgmts:\\" : strComputer : "\root\cimv2")
; Replace 'YourDeviceName' with the actual device name you are searching for
deviceName = "Logi"
WQL = "SELECT * FROM Win32_PnPEntity WHERE Name LIKE '%%" : deviceName : "%%'"
oP = oWMI.ExecQuery(WQL)
ForEach p in oP
svc = p.Service
caption = p.Caption
id = p.PNPDeviceID
Name = p.Name
desc = p.Description
manuf = p.Manufacturer
status = p.Status
Message("Device Info", "Service: " : svc : @LF : "Caption: " : caption : @LF : "PNPDeviceID: " : id : @LF : "Name: " : Name : @LF : "Description: " : desc : @LF : "Manufacturer: " : manuf : @LF : "Status: " : status)
Next
oP = 0
oWMI = 0
Exit
Quote from: JTaylor on October 11, 2024, 02:43:21 PMThis works for me using Name. Obviously, if you don't have a Logitec Camera you probably won't get anything.
Jim
Thanks Jim. So probably no 'one size fits all'. What did your 'Service' property report?
Actually, this shoe might fit all.
;Winbatch 2024 - find my camera
;it is WMI so should work with earlier versions
strComputer = "."
oWMI = GetObject( "winmgmts:\\" : strComputer : "\root\cimv2")
WQL = "SELECT * FROM Win32_PnPEntity WHERE PNPClass like '%%camera%%'"
oP= oWMI.ExecQuery(WQL)
ForEach p in oP
svc = p.Service
caption = p.PNPDeviceID
id = p.PNPClass
Name= p.Name
Message("Camera",svc:@LF:caption:@LF:id:@LF:Name)
Next
oP=0
oWMI=0
Exit
[EDIT]
Normally the status would be OK, but if disabled showed be 'Error'. Looking into code to disable, enable based on PNPDeviceID
That would probably cover many. All depends on how the manufacturer named the camera.
Jim
It depended on the part of the camera it was checking...I had 4 returns for one camera. I had
usbccgp
usbvideo
usbaudio
[blank]
Quote from: spl on October 12, 2024, 02:32:28 AMThanks Jim. So probably no 'one size fits all'. What did your 'Service' property report?
Quote from: JTaylor on October 12, 2024, 01:00:49 PMIt depended on the part of the camera it was checking...I had 4 returns for one camera. I had
I was only checking based on one assumed internal laptop webcam. Having additional external cameras would give multiple results. Any results other than "" would at least indicate a camera. Then as to how to enable/disable etc.. would depend on the InstanceID/DeviceID.
Below is my final shot
;Winbatch 2024 - find my camera
;it is WMI so should work with earlier versions
strComputer = "."
oWMI = GetObject( "winmgmts:\\" : strComputer : "\root\cimv2")
WQL = "SELECT * FROM Win32_PnPEntity WHERE PNPClass like '%%camera%%'"
oP= oWMI.ExecQuery(WQL)
ForEach p in oP
id = p.PNPDeviceID
class = p.PNPClass
name = p.Name
present = p.Present
if present == -1
present = "Present"
else
present = "Not Present"
endif
status = P.Status
if status == "OK"
status = "Enabled"
else
status = "Disabled"
endif
Message("Camera",id:@LF:class:@LF:name:@LF:present:@LF:status)
Next
oP=0
oWMI=0
Exit
I only have the one camera. Seems like WMI sees the audio as a separate device. Which, I guess, makes sense.
Seems like you have what you wanted.
Jim
Quote from: JTaylor on October 13, 2024, 04:16:41 PMSeems like you have what you wanted.
Jim
Pretty much. Just need to add Disable/Enable switch.