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