Jump to content

Webcam - present or not - (Moved)


AlexGo
 Share

Recommended Posts

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 by AlexGo
Link to comment
Share on other sites

@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")

 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

@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 :D:D:D 

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...