Sign in to follow this  
Followers 0
Apples292

List all connected Webcams

15 posts in this topic

Hey guys, I've searched around for on the forums but I haven't found it. Is there a way to look into all of the drivers and list all of the webcams there in a combo box or something... maybe someone has written a UDF for it or something. Anyway I need it for this project i'm working on. Any help is appreciated.

Thanks

Apples292

Share this post


Link to post
Share on other sites



Hi, Apples292. I don't have a webcam connected to test, but the code below should get you started. It queries WMI on the machine for a list of USB-connected devices. Once you find something that is unique to your cameras (the word camera in the name, for example), you can narrow the search and then feed the results into your GUI.

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$strComputer = "localhost"

$WMI = ObjGet("winmgmts:" & $strComputer & "rootCIMV2")
Local $aItems = $WMI.ExecQuery("SELECT * FROM Win32_USBDevice", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($aItems) then
   For $element In $aItems
    MsgBox(0, "======" & $element.Name & "======", "Manufacturer: " & $element.Manufacturer & @CRLF & @CRLF & "Description: " & $element.Description)
   Next
Else
   Msgbox(0,"","No WMI Objects Found for class: " & "Win32_USBDevice" )
Endif

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Thx for replying JLogan, I tried your code with and without a webcam (I also tried a memory stick) attached however I didn't get a MsgBox at all...

Am I missing something here, maybe I have to change this?

$strComputer = "localhost"

Thanks

Apples292

Share this post


Link to post
Share on other sites

Localhost is just the local computer. You can change it to use the @ComputerName macro, but it should not make a difference.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Nope... as u said it didn't make any difference. Maybe it's just that the webcam + USB stick isn't compatible I really have no idea...

Thanks

Apples292

P.S Do u have any idea why it doesn't send the

Msgbox(0,"","No WMI Objects Found for class: " & "Win32_USBDevice" )

because it should...

Edited by Apples292

Share this post


Link to post
Share on other sites

It should define everything in USB in WMI. Try adding this line:

MsgBox(0, "", "Yes, I am an object!")

right after the If IsObj line, and let me know what you see.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I did that, I now get the

MsgBox(0, "", "Yes, I am an object!")

everytime I run it, whether there is a webcam/USB stick in or not

Thanks

Apples292

BTW: This is what I've been trying

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$strComputer = "localhost"

$WMI = ObjGet("winmgmts:" & $strComputer & "rootCIMV2")
Local $aItems = $WMI.ExecQuery("SELECT * FROM Win32_USBDevice", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($aItems) then
MsgBox(0, "", "Yes, I am an object!")
For $element In $aItems
MsgBox(0, "======" & $element.Name & "======", "Manufacturer: " & $element.Manufacturer & @CRLF & @CRLF & "Description: " & $element.Description)
Next
Else
Msgbox(0,"","No WMI Objects Found for class: " & "Win32_USBDevice" )
Endif
Edited by Apples292

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

So, the MsgBox shows that it is obtaining the object correctly. You should be able to remove that line now, as it proved that you're good up to that point. The code looks right - can you tell me what Operating System and AutoIt Version you're running this in?

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Sorry I had to go somewhere

My OS = Windows XP Professional Version 2002

Autoit Version = 3.3.8.1

Thanks

Apples292

Share this post


Link to post
Share on other sites

What are you running this on? Windows XP Pro v 2002 is coming up listed as a 64 bit Itanium version of XP. Is that what you're running for an OS?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

I know Wikipedia shows Pro v 2002 as being Itanium, but I know it is not limited to that alone. For example, all of my VMs (both VMWare and VirtualBox) show up as this version.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Which is why I need the OP to tell me what it's running on.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

This is all I know or know how to get on my computer info...post-73139-0-89346600-1354562595_thumb.j

Thanks

Apples292

Share this post


Link to post
Share on other sites

When I run scriptomatic on 2 versions of Windows (Win7 x64, and XP x86) it doesn't show Win32_USBDevice on either machine. I'm not sure why that is, but it might not be available on all systems.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Okay, so it might not be possible? I guess that's okay but to do the webcam thing u'll probably have to set the default driver to the desired webcam eachtime... nvm

Thanks for all of the help guys :D

Apples292

Share this post


Link to post
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
Sign in to follow this  
Followers 0