Jump to content

WebCam example


rysiora
 Share

Recommended Posts

Hmm i have a PhilipsToU usb webcam.... keep getting black windows and the light on the webcam isn't burning.

Changed $WM_CAP_DRIVER_CONNECT from 0 till 9 and waited 2 minutes every time...

The webcam is working from "my computer"... is there something else i am doing wrong?

Link to comment
Share on other sites

Hmm i have a PhilipsToU usb webcam.... keep getting black windows and the light on the webcam isn't burning.

Changed $WM_CAP_DRIVER_CONNECT from 0 till 9 and waited 2 minutes every time...

The webcam is working from "my computer"... is there something else i am doing wrong?

Thats strange, I have a lego cam and it works from my computer and this script just fine. usually if you can view it from my computer the drivers have installed right so you should have no problem. maybe it just isnt compatable.

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

great idea, I havent tested it yet with my cams but I wana see if there is a way to make a motion sensing cam or even better a motion tracking cam.

Thanks man

Just take 20 points from a image and compare them with 20 points from another. If the images or off there is motion. (make sure it's not too sensitive though .. ). What i would like to see is face recognition, but i think AutoIt's too slow to do that on it's own.

Link to comment
Share on other sites

Just take 20 points from a image and compare them with 20 points from another. If the images or off there is motion. (make sure it's not too sensitive though .. ). What i would like to see is face recognition, but i think AutoIt's too slow to do that on it's own.

if we can do motion sensing, I think we can do a rough face recognition.

At least have it sense if it's a black guy or a white guy, LOL

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

Wow, Very funkeh, now for me to make the script, send the image to my email addy when the keys a e i o u are pressed, oh, and may aswell stil in a space, and while im at it, ill put in, hmm, maybe, mouseclick =D, Thanks again ^^

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

  • 2 weeks later...

;COPY CONSTANTS FROM PREVIOUS SCRIPTS IN THIS TOPIC

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
$avi = DllOpen("avicap32.dll")
$user = DllOpen("user32.dll")
$snapfile = @ScriptDir & "\scrshot.bmp"
$moviefile = @ScriptDir & "\moviecam.avi"

$Main = GUICreate("WebCam - Ready",350,300)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
$cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", 15, "int", 15, "int", 320, "int", 240, "hwnd", $Main, "int", 1)

DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0)
;DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 30, "int", 0)

$Combo = GUICtrlCreateCombo("Video Source",15,270,140,-1,$CBS_DROPDOWNLIST)
GUICtrlSetData(-1,"Video Display|Video Format|Compression","Video Source")
$Button = GUICtrlCreateButton("Show",170,270,100,21)
GUICtrlSetOnEvent(-1,"Button")

GUISetState(@SW_SHOW)
HotKeySet("{INSERT}", "SnapShot"); Press 'Insert' to make a SnapShot !
HotKeySet("{HOME}", "StartRecording"); Press 'Home' to start recording !

Func Quit()
;DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_CALLBACK_FRAME, "int", 0, "int", 0)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_END, "int", 0, "int", 0)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
;DllClose($avi); crashing, no one knows why...
    DllClose($user)
    Exit
EndFunc

Func Button()
    Switch GUICtrlRead($Combo)
        Case "Video Source"
            DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DLG_VIDEOSOURCE, "int", 0, "int", 0)
        Case "Video Display"
            DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DLG_VIDEODISPLAY, "int", 0, "int", 0)
        Case "Video Format"
            DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DLG_VIDEOFORMAT, "int", 0, "int", 0)
        Case "Compression"
            DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DLG_VIDEOCOMPRESSION, "int", 0, "int", 0)
    EndSwitch
EndFunc

While 1
    Sleep(1)
Wend

Func SnapShot()
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $snapfile)
EndFunc

Func StartRecording()
    WinSetTitle($Main, "", "WebCam - Capturing...")
    HotKeySet("{HOME}", "StopRecording")
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SET_CAPTURE_FILEA, "int", 0, "str", $moviefile)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SEQUENCE, "int", 0, "int", 0)
EndFunc

Func StopRecording()
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_STOP, "int", 0, "int", 0)
    WinSetTitle($Main, "", "WebCam - Ready")
    HotKeySet("{HOME}", "StartRecording")
EndFunc

The 4 dialogs are available. As they are depending of drivers, for every camera/driver they will possibly look other. If someone wants to change the compression of recorded movie - have a look on the Compression Dialog.

I also have problems with capturing (laggy, problems with stopping...) but I've already written about this.

Don't know how to fix it yet. Any ideas and experiments are welcome.

Edited by rysiora
Link to comment
Share on other sites

  • 2 weeks later...

I have a logitech 4000 camera and when i attempt to run the script nothing is happening just black screen. i updated the drivers and still the camera will not turn on and snap the pic? what type of camera are you using or that you can recommend to allow me to make this work it is pretty urgent i appriciate all your help.

kj

----------------

Are you sure you have drivers installed and your cam is working in other programs? Or maybe you have your cam connected with other computer and using it by network - if so I can't help you yet.

You can try to change

DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 1, "int", 0)

To 1,2 or other number if you have few devices/drivers of this type and your video driver is not the first one(index 0 is default).

Here is a sample of capturing to avi. It's not working perfectly, its very slow and sometimes stopping but it should work

;SIMPLY ADD THIS TO PREVIOUS SCRIPT FROM MY FIRST POST.
HotKeySet("{HOME}", "StartRecording"); Press 'Home' to start recording !

Func StartRecording()
    WinSetTitle($Main, "", "WebCam - Capturing...")
    HotKeySet("{HOME}", "StopRecording")
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SET_CAPTURE_FILEA, "int", 0, "str", $moviefile)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SEQUENCE, "int", 0, "int", 0)
EndFunc

Func StopRecording()
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_STOP, "int", 0, "int", 0)
    WinSetTitle($Main, "", "WebCam - Ready")
    HotKeySet("{HOME}", "StartRecording")
EndFunc
Link to comment
Share on other sites

Awesome, congratulation to rysiora!!!

I need it just for screenshot (without GUI): which piece(s) of code have I to delete/change?

look at my code and just take out the tcp stuff

http://www.autoitscript.com/forum/index.ph...st&p=213646

Edited by zerocool60544

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

need help? i have tried 2 web cams and this script is not working? i downloaded autoit, made an au3 file in the examples dir. yet still when i press insert i get a black pic.? is their a particular camera i need? i have tried a logitech 4000 web cam and an icatch vi pc camera? and both give me black pics? i change the value of "DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", X , "int", 0) - tried where X = 0, 1, 2, 3? do i have to save the file then wait a sec then try to snap the pic again? i hear people talking about the waiting. i appreciate any help, i need this code to work for an application @ work where when a user clicks a submit button on a web page i have made, i can snap a pic of them and save the pic to where i can specify. plz advise am i missing another script or ???

Link to comment
Share on other sites

i also have this doulbe cam problem.

i have fake webcam on my pc and a real one.

the fake is showing a red screen and the otherone show ME :whistle:

but now i can't choose.. it just shows the red one, but i need the me one.

any solutions ?

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

$WM_CAP_START = 0x400
$WM_CAP_UNICODE_START = $WM_CAP_START +100 
$WM_CAP_PAL_SAVEA = $WM_CAP_START + 81 
$WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81 
$WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW 
$WM_CAP_ABORT = $WM_CAP_START + 69 
$WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46 
$WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43 
$WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41 
$WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42 
$WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10 
$WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11 
$WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14 
$WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12 
$WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12 
$WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13 
$WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13 
$WM_CAP_EDIT_COPY = $WM_CAP_START + 30 
$WM_CAP_END = $WM_CAP_UNICODE_END 
$WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22 
$WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21 
$WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21 
$WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23 
$WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23 
$WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25 
$WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25 
$WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20 
$WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20 
$WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24 
$WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36 
$WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1 
$WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67 
$WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67 
$WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65 
$WM_CAP_GET_STATUS = $WM_CAP_START + 54 
$WM_CAP_GET_USER_DATA = $WM_CAP_START + 8 
$WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44 
$WM_CAP_GRAB_FRAME = $WM_CAP_START + 60 
$WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61 
$WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83 
$WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84 
$WM_CAP_PAL_OPENA = $WM_CAP_START + 80 
$WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80 
$WM_CAP_PAL_PASTE = $WM_CAP_START + 82 
$WM_CAP_SEQUENCE = $WM_CAP_START + 62 
$WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63 
$WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35 
$WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85 
$WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2 
$WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2 
$WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5 
$WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3 
$WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3 
$WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6 
$WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7 
$WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4 
$WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66 
$WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66 
$WM_CAP_SET_OVERLAY = $WM_CAP_START + 51 
$WM_CAP_SET_PREVIEW = $WM_CAP_START + 50 
$WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52 
$WM_CAP_SET_SCALE = $WM_CAP_START + 53 
$WM_CAP_SET_SCROLL = $WM_CAP_START + 55 
$WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64 
$WM_CAP_SET_USER_DATA = $WM_CAP_START + 9 
$WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45 
$WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72 
$WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71 
$WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70 
$WM_CAP_STOP = $WM_CAP_START + 68

#include <GUIConstants.au3>
$avi = DllOpen("avicap32.dll")
$user = DllOpen("user32.dll")
$snapfile = @ScriptDir & "\scrshot.bmp"

$Main = GUICreate("Camera",350,270)
$cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", 15, "int", 15, "int", 320, "int", 240, "hwnd", $Main, "int", 1)

DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0)

GUISetState(@SW_SHOW)
HotKeySet("{INSERT}", "SnapShot"); Press 'Insert' to make a SnapShot !

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
    ;DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_CALLBACK_FRAME, "int", 0, "int", 0)
        DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_END, "int", 0, "int", 0)
        DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
    ;DllClose($avi)
        DllClose($user)
        Exit
    EndIf
    Sleep(1)
Wend

Func SnapShot()
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $snapfile)
EndFunc

Maybe someone would find it useful. Insert is the HotKey for making photos.

Rysoria !

This is excellent .. works fine for me .

But the picture uppdates very slowly on some browsers and nothing at all , on Some !

Something to fix from script or from the user ???

Link to comment
Share on other sites

  • 9 months later...

Hi

Need a small help from forum members....

(1) Is it possible to save the snapshot an a JPG / PNG.

(2) Can I add a Time Stamp on the Image? If so, some help please.

and hey Rysiora, its an awesome script.

Working first attempt with no problems.

Thx to all in advance.

regards,

Vai

Link to comment
Share on other sites

$WM_CAP_START = 0x400
$WM_CAP_UNICODE_START = $WM_CAP_START +100 
$WM_CAP_PAL_SAVEA = $WM_CAP_START + 81 
$WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81 
$WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW 
$WM_CAP_ABORT = $WM_CAP_START + 69 
$WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46 
$WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43 
$WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41 
$WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42 
$WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10 
$WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11 
$WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14 
$WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12 
$WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12 
$WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13 
$WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13 
$WM_CAP_EDIT_COPY = $WM_CAP_START + 30 
$WM_CAP_END = $WM_CAP_UNICODE_END 
$WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22 
$WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21 
$WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21 
$WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23 
$WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23 
$WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25 
$WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25 
$WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20 
$WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20 
$WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24 
$WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36 
$WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1 
$WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67 
$WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67 
$WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65 
$WM_CAP_GET_STATUS = $WM_CAP_START + 54 
$WM_CAP_GET_USER_DATA = $WM_CAP_START + 8 
$WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44 
$WM_CAP_GRAB_FRAME = $WM_CAP_START + 60 
$WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61 
$WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83 
$WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84 
$WM_CAP_PAL_OPENA = $WM_CAP_START + 80 
$WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80 
$WM_CAP_PAL_PASTE = $WM_CAP_START + 82 
$WM_CAP_SEQUENCE = $WM_CAP_START + 62 
$WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63 
$WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35 
$WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85 
$WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2 
$WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2 
$WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5 
$WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3 
$WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3 
$WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6 
$WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7 
$WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4 
$WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66 
$WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66 
$WM_CAP_SET_OVERLAY = $WM_CAP_START + 51 
$WM_CAP_SET_PREVIEW = $WM_CAP_START + 50 
$WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52 
$WM_CAP_SET_SCALE = $WM_CAP_START + 53 
$WM_CAP_SET_SCROLL = $WM_CAP_START + 55 
$WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64 
$WM_CAP_SET_USER_DATA = $WM_CAP_START + 9 
$WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45 
$WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72 
$WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71 
$WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70 
$WM_CAP_STOP = $WM_CAP_START + 68

#include <GUIConstants.au3>
$avi = DllOpen("avicap32.dll")
$user = DllOpen("user32.dll")
$snapfile = @ScriptDir & "\scrshot.bmp"

$Main = GUICreate("Camera",350,525)
$cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", 15, "int", 15, "int", 320, "int", 240, "hwnd", $Main, "int", 1)

DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 2, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0)

$cap1 = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", 15, "int", 275, "int", 320, "int", 240, "hwnd", $Main, "int", 1)

DllCall($user, "int", "SendMessage", "hWnd", $cap1[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap1[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap1[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap1[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap1[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0)

GUISetState(@SW_SHOW)
HotKeySet("{INSERT}", "SnapShot"); Press 'Insert' to make a SnapShot !

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
    ;DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_CALLBACK_FRAME, "int", 0, "int", 0)
        DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_END, "int", 0, "int", 0)
        DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
    ;DllClose($avi)
        DllClose($user)
        Exit
    EndIf
    Sleep(1)
Wend

Func SnapShot()
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $snapfile)
EndFunc

That displays two webcams.

Link to comment
Share on other sites

  • 5 weeks later...

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...