Python Forum

Full Version: get webcam name from device manger !!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hello all ...
how i can get my webcam name by python ??

in powershell i can use this command:
Quote: Get-WmiObject Win32_PNPEntity | Select Name | Select-String "Camera"

output :
Quote:@{Name=HP Wide Vision HD Camera}
[Image: Capture.png]

how i can do this in pure python ?
solved :

import wmi
import re


c = wmi.WMI()
wql = "Select * From Win32_USBControllerDevice"
for item in c.query(wql):
    q = item.Dependent.Caption
    if re.findall("Camera",q):
        print(q)
    
    
Output:
HP Wide Vision HD Camera
Glad you got the solution, and thanks for coming back to share it!