AlexGo Posted September 8, 2018 Share Posted September 8, 2018 Hello! How I can detect with Autoit if a webcam in system present? I don't need to manage the camera, but only discover availability. Any idee? Thanks for help! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 8, 2018 Moderators Share Posted September 8, 2018 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted September 9, 2018 Share Posted September 9, 2018 @AlexGo Hi, and welcome to the AutoIt forum Take a look here. There are a tons of samples using WMI with AutoIt on the forum Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
AlexGo Posted September 9, 2018 Author Share Posted September 9, 2018 (edited) @FrancescoDiMuro Great! Thanks a lot for you answer! Edited September 10, 2018 by AlexGo Link to comment Share on other sites More sharing options...
AlexGo Posted September 9, 2018 Author Share Posted September 9, 2018 (edited) Ok. If anybody need: #include <Array.au3> WebCam () Func WebCam () $PnPobjWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2") $colItemsPnP = $PnPobjWMIService.ExecQuery("SELECT PNPClass from Win32_PnPEntity") Local $PnPDevices [1000][1], $i = 0 For $objItemPnP in $colItemsPnP With $objItemPnP $PnPDevices[$i][0] = .PNPClass EndWith $i += 1 Next Return _ArraySearch ($PnPDevices, 'Camera') EndFunc It would be nice to see your opinion Edited September 10, 2018 by AlexGo Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted September 10, 2018 Share Posted September 10, 2018 @AlexGo Happy to have helped By the way, I was thinking that you can "short" your code in this way, premising that you have only a webcam $PnPobjWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2") $colItemsPnP = $PnPobjWMIService.ExecQuery("SELECT Description from Win32_PnPEntity") For $objItemPnP in $colItemsPnP If $objItemPnP.Description = "USB-Videogerät" Then Exit MsgBox(0,"","Webcam ist verfügbar") Next MsgBox (0,"", "Webcam ist nicht verfügbar") AlexGo 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
AlexGo Posted September 13, 2018 Author Share Posted September 13, 2018 @FrancescoDiMuro "Short" version looks good! But "webcam availability" is only a part of my program. That's why I made it like a function. And I found that "USB-Videogerät" not for every laptop valid. So I changed "Description" for "PNPClass" it is more universal - function search now for "Camera" (works independently of language) . But I also found that the webcam can be in the "Imaging devices" section of Windows device manager. In "PNPClass" it's called "Image". So I have a lot of fun Now it looks like this: #include <Array.au3> WebCam () Func WebCam () $PnPobjWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2") $colItemsPnP = $PnPobjWMIService.ExecQuery("SELECT PNPClass, Caption from Win32_PnPEntity") Local $PnPDevices [1000][2], $i = 0 For $objItemPnP in $colItemsPnP With $objItemPnP $PnPDevices[$i][0] = .PNPClass $PnPDevices[$i][1] = .Caption EndWith $i += 1 Next $wCamera = _ArraySearch ($PnPDevices, 'Camera') $wImage = _ArraySearch ($PnPDevices, 'Image') If $wCamera = -1 And $wImage = -1 Then Msgbox (1,"", "Wecam is not available") Else Msgbox (1,"", "Wecam is available") EndIf EndFunc if a system has a scanner then Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now