- Offizieller Beitrag
Hi,
ich habe hier eine kleine Oberfläche für meine Webcam erstellt. (Es ist noch nicht alles fertig)
Mein Problem:
Wenn ich die Kamera aktiviere (das funktioniert) anschließend deaktiviere und erneut aktivieren möchte, läßt sie sich nicht mehr einschalten.
Passiert in der Funktion _CameraOnOff() ab Zeile 338.
Einen Teil der Daten habe ich im Spoiler gekürzt - im Anhang ist alles komplett.
Hat jemand eine Idee?
Spoiler anzeigen
#Region - TimeStamp
; 2011-08-23 01:20:46 v 0.2
#EndRegion - TimeStamp
; =============================================================================
; Titel..........: MyWebcam.au3
; Beschreibung...: Webcam live, Aufzeichnung/Wiedergabe Schnappschuß/Video
; Version AutoIt.: 3.3.6.1
; Author.........: BugFix
; ...............: Webcam Funktionen von Ludocus und pierrotm777
; =============================================================================
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
Opt('GuiOnEventMode', 1)
Opt('MustDeclareVars', 1)
Global Const $WM_CAP_START = 0x400
Global Const $WM_CAP_UNICODE_START = $WM_CAP_START +100
Global Const $WM_CAP_PAL_SAVEA = $WM_CAP_START + 81
Global Const $WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81
Global Const $WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW
Global Const $WM_CAP_ABORT = $WM_CAP_START + 69
Global Const $WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46
Global Const $WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43
Global Const $WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41
Global Const $WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42
Global Const $WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10
Global Const $WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11
Global Const $WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14
Global Const $WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12
Global Const $WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12
Global Const $WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13
Global Const $WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13
Global Const $WM_CAP_EDIT_COPY = $WM_CAP_START + 30
Global Const $WM_CAP_END = $WM_CAP_UNICODE_END
Global Const $WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22
Global Const $WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21
Global Const $WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21
Global Const $WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23
Global Const $WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23
Global Const $WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25
Global Const $WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25
Global Const $WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20
Global Const $WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20
Global Const $WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24
Global Const $WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36
Global Const $WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1
Global Const $WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67
Global Const $WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67
Global Const $WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65
Global Const $WM_CAP_GET_STATUS = $WM_CAP_START + 54
Global Const $WM_CAP_GET_USER_DATA = $WM_CAP_START + 8
Global Const $WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44
Global Const $WM_CAP_GRAB_FRAME = $WM_CAP_START + 60
Global Const $WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61
Global Const $WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83
Global Const $WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84
Global Const $WM_CAP_PAL_OPENA = $WM_CAP_START + 80
Global Const $WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80
Global Const $WM_CAP_PAL_PASTE = $WM_CAP_START + 82
Global Const $WM_CAP_SEQUENCE = $WM_CAP_START + 62
Global Const $WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63
Global Const $WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35
Global Const $WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85
Global Const $WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2
Global Const $WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2
Global Const $WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5
Global Const $WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3
Global Const $WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3
Global Const $WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6
Global Const $WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7
Global Const $WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4
Global Const $WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66
Global Const $WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66
Global Const $WM_CAP_SET_OVERLAY = $WM_CAP_START + 51
Global Const $WM_CAP_SET_PREVIEW = $WM_CAP_START + 50
Global Const $WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52
Global Const $WM_CAP_SET_SCALE = $WM_CAP_START + 53
Global Const $WM_CAP_SET_SCROLL = $WM_CAP_START + 55
Global Const $WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64
Global Const $WM_CAP_SET_USER_DATA = $WM_CAP_START + 9
Global Const $WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45
Global Const $WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72
Global Const $WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71
Global Const $WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70
Global Const $WM_CAP_STOP = $WM_CAP_START + 68
Global $avicap = DllOpen("avicap32.dll")
Global $user = DllOpen("user32.dll")
#region - Iconsource
; registriert die Funktion "_DelBinaryTempFiles()", damit die temporär erstellten Dateien bei Beendigung wieder gelöscht werden
OnAutoItExitRegister("_DelBinaryTempFiles")
Local $bData[13] = [12]
[/autoit] [autoit][/autoit] [autoit]; String mit den Binärdaten von: camera-web.ico
$bData[1] &= "0x0000010001003030000000000000A82500001600000028000000300000006000000001002000000000000024000000000000000000000000000000000...."
$bData[1] &= "000000000000000000000000000001000000050000000D000000170000001F1413103A33312CB9424240FF4E5150FF555857FF5A5D5CFF5E615FFF5F63...."
$bData[1] &= "4E48FF4D4945FF3F3E3CFF40403EFF7C7C7BFFCBCBCBFFD4D4D4FFC8C8C8FFB9B9B9FFB8B8B8FFC3C3C3FFC6C6C6FFD1D1D1FFCFD0CFFF7A7C7AE...."
$bData[1] &= "000000000000000000000000000000000000000000000000000000000000000000000000000000515553065D605E7D9FA1A0F8E0E0E0FFDCDCDCFFE0E...."
$bData[1] &= "9694D6B4B7B6F8D7D6D5FFDDCBBDFFCBA78BFFC49A7AFFC39776FFC39675FFC39675FFC39776FFC49A7AFFCCA88BFFDECCBFFFD7D7D5FFB3B6B...."
; String mit den Binärdaten von: camera_photo1.gif
$bData[2] &= "0x47494638396130003000F700000000001E4F65364E59384F5A38505B3B535D20516624546929596E2C5C72335D6F3F566031607636657A3B6172386...."
$bData[2] &= "00270C6287513C4354CEC0850B6EA00639F802136C48820B14718B5D1401978B78C43527400146AC22164BDC64307D63102CEC424BD928C50B92A0...."
; String mit den Binärdaten von: camera_photo2.gif
$bData[3] &= "0x47494638396130003000F700000000001E4F65364E59384F5A38505B3B535D20516624546929596E2C5C72335D6F3F566031607636657A3B6172386...."
$bData[3] &= "00270C6287513C6354CEC0850B6EA00639F802136C48820B14718B5D1401978B78C43527400146AC22164BDC64307F63102CEC624BD928C50B92A00...."
; String mit den Binärdaten von: camera_video_rec0.gif
$bData[4] &= "0x47494638396130003000F700000000000303030500050606060909090D0D0C001800091E09120E121212121612161515151919191D1D1D0E210E0033...."
$bData[4] &= "86A2AC510C71046316D5880624370549666C5023DFD0C73CE4710F10CE631DD558C73CACE18D6F24431CF880C62EB6F14A6449E395C268454C6CE10...."
; String mit den Binärdaten von: camera_video_rec1.gif
$bData[5] &= "0x47494638396130003000F700000000000500050606060B0B0B001800091E09120E121212121612161515151919191D1D1D0E210E003500043E041829...."
$bData[5] &= "862EB0418D44A2610C5680E525C5801170E8631EF2B8C705E7B10E6CAC631ED9F8063824870FA6742395D438431494794929608417FEC80635A271CD...."
; String mit den Binärdaten von: camera_video_rec2.gif
$bData[6] &= "0x47494638396130003000F700000000000500050606060B0B0B001800091E09120E121212121612161515151919191D1D1D0E210E003500043E041829...."
$bData[6] &= "C6297B51862DB4B29550400246C0A18F79C8E31E129CC73AB0B18E7964E31BE0701C3E98D20D527E63176260E531A1C08420400417FEC80635A251C...."
; String mit den Binärdaten von: config_tool.gif
$bData[7] &= "0x47494638396130003000F70000000000153E0C1F5B0A3B5F382668072A700E357C1833672E3975383D7C31437D1C4A7C2449484950524F515351595...."
; String mit den Binärdaten von: config_tool1.gif
$bData[8] &= "0x47494638396130003000F70000000000153E0C1F5B0A3B5F382668072A700E357C1833672E3975383D7C31437D1C4A7C2449484950524F515351595...."
; String mit den Binärdaten von: folder_records.gif
$bData[9] &= "0x47494638396130003000F7000000000062440E6365397F7624616F427A7C6B3E7ECA417CC118BA7824C6793DDB7F7EAD6F52D07E5E89AC5CB78571...."
; String mit den Binärdaten von: folder_records1.gif
$bData[10] &= "0x47494638396130003000F7000000000062440E6365397F7624616F427A7C6B3E7ECA417CC118BA7824C6793DDB7F7EAD6F52D07E5E89AC5CB7857...."
; String mit den Binärdaten von: media_start.ico
$bData[11] &= "0x0000010001003030000001002000A8250000160000002800000030000000600000000100200000000000004800000000000000000000000000000000...."
$bData[11] &= "B43C7F6AB43C7F7CAA3DB6739C23D771B13DB6ADCCB3DB548DEEFD246DF2FF246DF1FF236DF1FF236CF2FF236CF1FF236BF1FF236BF1FF236BF1F...."
$bData[11] &= "FDFFFFBCD4F8FE5C97F3FE468AF4FF347EF3FF2776F3FF2474F2FF2573F2FF2473F2FF2673F2FFA4ABA7F260613EE1A29234CCC2A65BE2A56102FF9...."
$bData[11] &= "854AA1C8A85D91C19149F3A56000BE8F8B34FF768522DB6FB03B856AB43C7F848C5DBF328BEAFF298CF7FF298CF7FF298CF7FF298BF6FF298BF6FF...."
$bData[11] &= "A7D4FF6EABE7FF68ADF0FF68ADF0FF6EADEBFF7FADDFFF97ADC9FDAEAAACF7B8A490EEBDA883E6CFB481E2D5B782E1D5B782E1D5B782E1D5B782...."
; String mit den Binärdaten von: media_select.ico
$bData[12] &= "0x0000010001003030000001002000A8250000160000002800000030000000600000000100200000000000004800000000000000000000000000000000...."
$bData[12] &= "DDF4FF7ADFF7FF78DEF7FF76DDF7FF74DCF6FF73DCF6FF72DCF6FF9FD2E6FF88A1B0FF7A909DFF51636CFF6E7A81FF7FA2AFFF63AEC2FF5EAEC4FF...."
$bData[12] &= "E4EAFFBAE5EBFFB9E4EBFFC5E6ECFFCDEAECFFCCE9ECFFCCE8EBFFD6E6E8D8F2ECE7A3F1EBE5AAF4EDE3AFE5DBD0D8BBB9B8FE929293F46561614..."
$bData[12] &= "0000000000000000000000000000000000000000000000B3E0F1FFB0F3FFFFB0F1FEFFB0F6FFFFB2F7FFFFB2F7FFFFB2F7FFFFB2F7FFFFB3F7FFFFD7F...."
$bData[12] &= "E4F4FF99E5F5FF9FE8F6FFA9EBF7FFB2EDF8FFB9EFF9FFC5F2FBFFCCF3FCFFCCF4FBFFCBF3FBFFC5F3FBFFC1F2FBFFBDF1FBFF9EEFFCFF000000000...."
; erstellt im TEMPDIR die Datei/-en aus allen vorhandenen $bData Variablen
Dim $bDatanames[12] = ["camera-web.ico","camera_photo1.gif","camera_photo2.gif","camera_video_rec0.gif","camera_video_rec1.gif","camera_video_rec2.gif","config_tool.gif","config_tool1.gif","folder_records.gif","folder_records1.gif","media_start.ico","media_select.ico"]
For $i = 1 To $bData[0]
Local $sFile = @ScriptDir & "\" & $bDatanames[$i -1]
Local $hFileOut = FileOpen($sFile, 2+8+16)
FileWrite($hFileOut, Binary($bData[$i]))
FileClose($hFileOut)
Next
Func _DelBinaryTempFiles()
For $i = 1 To $bData[0] - 1
FileDelete(@ScriptDir & "\" & $bDatanames[$i - 1])
Next
EndFunc
#endregion - Iconsource
Global $pic_Photo1 = @ScriptDir & '\' & $bDatanames[1]
Global $pic_Photo2 = @ScriptDir & '\' & $bDatanames[2]
Global $pic_Video0 = @ScriptDir & '\' & $bDatanames[3]
Global $pic_Video1 = @ScriptDir & '\' & $bDatanames[4]
Global $pic_Video2 = @ScriptDir & '\' & $bDatanames[5]
Global $pic_Config = @ScriptDir & '\' & $bDatanames[6]
Global $pic_Config1 = @ScriptDir & '\' & $bDatanames[7]
Global $pic_Records = @ScriptDir & '\' & $bDatanames[8]
Global $pic_Records1 = @ScriptDir & '\' & $bDatanames[9]
Global $icon_MediaRun = @ScriptDir & '\' & $bDatanames[10]
Global $icon_MediaSel = @ScriptDir & '\' & $bDatanames[11]
Global $aSavePath[2] = [@HomeDrive & @HomePath,@HomeDrive & @HomePath]
Global $hWnd_Camera, $hWnd_Config, $hWnd_Records, $fRecord_active = False
Global $MyWebcamApp_INI = @ScriptDir & '\MyWebcamApp.INI'
If FileExists($MyWebcamApp_INI) Then
$aSavePath[0] = IniRead($MyWebcamApp_INI, 'pathes', 'snap', @HomeDrive & @HomePath)
$aSavePath[1] = IniRead($MyWebcamApp_INI, 'pathes', 'video', @HomeDrive & @HomePath)
EndIf
Global $idCam, $isCamera = 0, $picPhoto, $picVideo, $picRecord, $picConfig, $rVideo, $inPath, $inPathSnap, $inPathVideo, $btCamera
[/autoit] [autoit][/autoit] [autoit]#region - Webcam Fenster
$hWnd_Camera = GUICreate('Webcam', 340, 348, -1, -1)
GUISetIcon(@ScriptDir & '\' & $bDatanames[0])
GUISetBkColor(0x000000)
GUISetOnEvent($GUI_EVENT_CLOSE, '_exit', $hWnd_Camera)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, '_MDown', $hWnd_Camera)
GUISetOnEvent($GUI_EVENT_PRIMARYUP, '_MUp', $hWnd_Camera)
GUICtrlCreateGroup('', 8, 2, 324, 250)
GUICtrlCreateGroup('', -99, -99, 1, 1)
;~ $idCam = _WebcamOpen($hWnd_Camera, 10, 10, 320, 240)
$picPhoto = GUICtrlCreatePic($pic_Photo1, 10, 260, 48, 48)
$picVideo = GUICtrlCreatePic($pic_Video0, 99, 260, 48, 48)
$picRecord = GUICtrlCreatePic($pic_Records, 188, 260, 48, 48)
$picConfig = GUICtrlCreatePic($pic_Config, 278, 260, 48, 48)
$btCamera = GUICtrlCreateButton('Kamera EIN', 110, 315, 120, 25, $BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent(-1, '_CameraOnOff')
GUICtrlSetColor(-1, 0x008000)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetFont(-1, 10, 600)
#endregion
#region - Records Fenster
$hWnd_Records = GUICreate("Aufzeichnungen", 340, 250, 285, 129)
GUISetOnEvent($GUI_EVENT_CLOSE, '_HideRecords', $hWnd_Records)
GUICtrlCreateGroup(" Datentyp ", 16, 16, 305, 121)
GUICtrlCreateRadio("Schnappschuß", 40, 48, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$rVideo = GUICtrlCreateRadio("Video", 40, 88, 113, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$inPath = GUICtrlCreateInput("", 16, 150, 305, 21)
GUICtrlCreateButton("", 40, 185, 48, 48, $BS_ICON)
GUICtrlSetOnEvent(-1, '_SelectFile')
GUICtrlSetImage(-1, $icon_MediaSel)
GUICtrlCreateButton("", 252, 185, 48, 48, $BS_ICON)
GUICtrlSetOnEvent(-1, '_PlayFile')
GUICtrlSetImage(-1, $icon_MediaRun)
#endregion
#region - Config Fenster
$hWnd_Config = GUICreate("Standardpfade", 340, 200, 285, 129)
GUISetOnEvent($GUI_EVENT_CLOSE, '_HideConfig', $hWnd_Config)
GUICtrlCreateLabel('Schnappschuß', 10, 30)
GUICtrlCreateButton('', 313, 30, 17, 17)
GUICtrlSetOnEvent(-1, '_SelectFolderSnap')
$inPathSnap = GUICtrlCreateInput($aSavePath[0], 10, 60, 320, 21)
GUICtrlCreateLabel('Video', 10, 110)
GUICtrlCreateButton('', 313, 110, 17, 17)
GUICtrlSetOnEvent(-1, '_SelectFolderVideo')
$inPathVideo = GUICtrlCreateInput($aSavePath[1], 10, 140, 320, 21)
#endregion
WinSetOnTop($hWnd_Camera, '', 1)
GUISetState(@SW_SHOW, $hWnd_Camera)
While True
Sleep(50)
WEnd
Func _exit()
If $fRecord_active Then ; Aufzeichnung läuft noch
_WebcamRecordStop($idCam)
_CameraOnOff()
EndIf
Exit
EndFunc
Func _MDown()
Local $cursor = GUIGetCursorInfo($hWnd_Camera)
Switch $cursor[4]
Case $picPhoto
GUICtrlSetImage($picPhoto, $pic_Photo2)
Case $picVideo
If Not $fRecord_active Then
$fRecord_active = True
Else
_WebcamRecordStop($idCam)
AdlibUnRegister('_ToggleRecordPict')
AdlibUnRegister('_SetTitle')
$fRecord_active = False
GUICtrlSetImage($picVideo, $pic_Video0)
EndIf
Case $picConfig
GUICtrlSetImage($picConfig, $pic_Config1)
Case $picRecord
GUICtrlSetImage($picRecord, $pic_Records1)
EndSwitch
EndFunc
Func _MUp()
Local $cursor = GUIGetCursorInfo($hWnd_Camera), $sFile, $sSave, $mb
Switch $cursor[4]
Case $picPhoto
GUICtrlSetImage($picPhoto, $pic_Photo1)
Local $sFile = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & '.bmp'
If _WebcamSnap($idCam, $aSavePath[0] & '\' & $sFile) = 1 Then
WinSetOnTop($hWnd_Camera, '', 0)
While True
Do
$sSave = InputBox('Schnappschuß speichern', 'Bitte Dateinamen eingeben')
If $sSave = '' Then $mb = MsgBox(262180, 'Kein Dateiname vergeben', 'Eingabe Wiederholen?')
Until $sSave <> '' Or $mb = 7
If $sSave = '' Or $mb = 7 Then
WinSetOnTop($hWnd_Camera, '', 1)
FileDelete($aSavePath[0] & '\' & $sFile)
Return
EndIf
If StringRight($sSave, 4) <> '.bmp' Then $sSave &= '.bmp'
If FileExists($aSavePath[0] & '\' & $sSave) Then
MsgBox(262192, 'Fehler', $sSave & ' existiert bereits!', 3)
Else
ExitLoop
EndIf
WEnd
FileMove($aSavePath[0] & '\' & $sFile, $aSavePath[0] & '\' & $sSave)
EndIf
WinSetOnTop($hWnd_Camera, '', 1)
Case $picConfig
GUICtrlSetImage($picConfig, $pic_Config)
WinSetOnTop($hWnd_Camera, '', 0)
WinSetOnTop($hWnd_Config, '', 1)
GUISetState(@SW_SHOW, $hWnd_Config)
Case $picVideo
If Not $fRecord_active Then
WinSetTitle($hWnd_Camera, '', 'Webcam')
Else
WinSetOnTop($hWnd_Camera, '', 0)
; == Video-Aufzeichnung funzt noch nicht ==
;~ While True
;~ Do
;~ $sSave = InputBox('Video speichern', 'Bitte Dateinamen eingeben')
;~ If $sSave = '' Then $mb = MsgBox(262180, 'Kein Dateiname vergeben', 'Eingabe Wiederholen?')
;~ Until $sSave <> '' Or $mb = 7
;~ If $sSave = '' Or $mb = 7 Then
;~ Return WinSetOnTop($hWnd_Camera, '', 1)
;~ EndIf
;~ If StringRight($sSave, 4) <> '.avi' Then $sSave &= '.avi'
;~ If FileExists($aSavePath[1] & '\' & $sSave) Then
;~ MsgBox(262192, 'Fehler', $sSave & ' existiert bereits!', 3)
;~ Else
;~ ExitLoop
;~ EndIf
;~ WEnd
;~ WinSetOnTop($hWnd_Camera, '', 1)
GUICtrlSetImage($picVideo, $pic_Video1)
AdlibRegister('_ToggleRecordPict', 500)
AdlibRegister('_SetTitle', 1000)
WinSetTitle($hWnd_Camera, '', 'Webcam [ Record-Time 00:00:00 ]')
;~ _WebcamRecordStart($sSave, $idCam)
EndIf
Case $picRecord
GUICtrlSetImage($picRecord, $pic_Records)
WinSetOnTop($hWnd_Camera, '', 0)
WinSetOnTop($hWnd_Records, '', 1)
GUISetState(@SW_SHOW, $hWnd_Records)
EndSwitch
EndFunc
Func _CameraOnOff()
If $isCamera = 0 Then
GUICtrlSetData($btCamera, 'Kamera AUS')
GUICtrlSetColor($btCamera, 0xFF0000)
$idCam = _WebcamOpen($hWnd_Camera, 10, 10, 320, 240)
Else
GUICtrlSetData($btCamera, 'Kamera EIN')
GUICtrlSetColor($btCamera, 0x008000)
_WebcamClose($idCam)
EndIf
$isCamera = BitXOR($isCamera, 1)
EndFunc
Func _ToggleRecordPict()
Local Static $iToggle = 0
If $fRecord_active Then
If $iToggle = 0 Then
GUICtrlSetImage($picVideo, $pic_Video1)
$iToggle = 1
Else
GUICtrlSetImage($picVideo, $pic_Video2)
$iToggle = 0
EndIf
EndIf
EndFunc
Func _SetTitle()
Local Static $sec = 0, $hour = 0, $min = 0
$sec += 1
Local $secShow, $minShow, $hourShow
If $sec > 59 Then
$min += 1
$sec = 0
EndIf
If $min > 59 Then
$hour += 1
$min = 0
EndIf
If $hour > 23 Then
$hour = 0
EndIf
WinSetTitle($hWnd_Camera, '', 'Webcam [ Record-Time ' & StringFormat('%02u', $hour) & ':' & StringFormat('%02u', $min) & ':' & StringFormat('%02u', $sec) & ' ]')
EndFunc
Func _HideRecords() ; Aufzeichnungsfenster ausblenden
WinSetOnTop($hWnd_Records, '', 0)
GUISetState(@SW_HIDE, $hWnd_Records)
WinSetOnTop($hWnd_Camera, '', 1)
EndFunc
Func _SelectFile() ; Auswahl im Fenster Aufzeichnungen
Local $aParam[2][2] = [['Schnappschuß wählen','Bilder (*.bmp)'], ['Video wählen','Videos (*.avi)']], $index = 0
If BitAND(GUICtrlRead($rVideo), $GUI_CHECKED) Then $index = 1
WinSetOnTop($hWnd_Records, '', 0)
Local $sFile = FileOpenDialog($aParam[$index][0], $aSavePath[$index], $aParam[$index][1], 3)
Local $error = @error
WinSetOnTop($hWnd_Records, '', 1)
If $error Then Return
GUICtrlSetData($inPath, $sFile)
EndFunc
Func _PlayFile() ; Ausgewählte Datei wiedergeben
Local $sFile = GUICtrlRead($inPath)
If Not FileExists($sFile) Then Return
WinSetOnTop($hWnd_Records, '', 0)
ShellExecuteWait($sFile)
WinSetOnTop($hWnd_Records, '', 1)
GUICtrlSetData($inPath, '')
EndFunc
Func _HideConfig()
Local $sSnap = GUICtrlRead($inPathSnap)
If Not FileExists($sSnap) Then $sSnap = $aSavePath[0]
Local $sVideo = GUICtrlRead($inPathVideo)
If Not FileExists($sVideo) Then $sVideo = $aSavePath[1]
If $sSnap <> $aSavePath[0] Or $sVideo <> $aSavePath[1] Then
IniWrite($MyWebcamApp_INI, 'pathes', 'snap', $sSnap)
IniWrite($MyWebcamApp_INI, 'pathes', 'video', $sVideo)
EndIf
WinSetOnTop($hWnd_Config, '', 0)
GUISetState(@SW_HIDE, $hWnd_Config)
WinSetOnTop($hWnd_Camera, '', 1)
EndFunc
Func _SelectFolderSnap()
WinSetOnTop($hWnd_Config, '', 0)
Local $sSnap = FileSelectFolder('Speicher-Ordner für Schnappschüsse wählen', $aSavePath[0], 7)
Local $error = @error
WinSetOnTop($hWnd_Config, '', 1)
If $error Then Return
GUICtrlSetData($inPathSnap, $sSnap)
EndFunc
Func _SelectFolderVideo()
WinSetOnTop($hWnd_Config, '', 0)
Local $sVideo = FileSelectFolder('Speicher-Ordner für Videos wählen', $aSavePath[1], 7)
Local $error = @error
WinSetOnTop($hWnd_Config, '', 1)
If $error Then Return
GUICtrlSetData($inPathVideo, $sVideo)
EndFunc
; ==================== webcam - UDF von Ludocus ==========================================================================================
[/autoit] [autoit][/autoit] [autoit];===============================================================================
;
; Description: Open's a webcam preview screen in your gui
; Syntax: _WebcamOpen($sHwnd, $sLeft, $sTop, $sWidth, $sHeight)
; Parameter(s): $sHwnd - The handle of the gui
; $sLeft - Left coord. of the preview screen
; $sTop - Top coord. of the preview screen
; $sWidth - Width of the preview screen
; $sHeight - Height of the preview screen
; Requirement(s): A webcam
; Return Value(s): On Success - Returns id needed for other controls
; On Failure - Returns -1
; Author(s): Ludocus
; Note(s): None
;
;===============================================================================
func _WebcamOpen($sHwnd, $sLeft, $sTop, $sWidth, $sHeight,$WebCamId=0)
Local $cap = DllCall($avicap, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", $sLeft, "int", $sTop, "int", $sWidth, "int", $sHeight, "hwnd", $sHwnd, "int", 1)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", $WebCamId , "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)
if @error then return -1
return $cap[0]
EndFunc
;===============================================================================
;
; Description: Creates a Snapshot from a webcam
; Syntax: _WebcamSnap($sId, $sFile)
; Parameter(s): $sId - Id (returned from _WebcamOpen)
; $sFile - File to save the snapshot to (*.bmp)
; Requirement(s): A webcam
; Return Value(s): On Success - Returns 1
; On Failure - Returns 0
; Author(s): Ludocus
; Note(s): None
;
;===============================================================================
Func _WebcamSnap($sId, $sFile)
; DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SET_CALLBACK_FRAME, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $sFile)
if @error Then
return 0
Else
return 1
EndIf
EndFunc
;===============================================================================
;
; Description: Closes the preview screen created with _WebcamOpen
; Syntax: _WebcamClose($sId)
; Parameter(s): $sId - Id (returned from _WebcamOpen)
; Requirement(s): A webcam
; Return Value(s): On Success - Returns 1
; On Failure - Returns 0
; Author(s): Ludocus
; Note(s): None
;
;===============================================================================
Func _WebcamClose($sId)
DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SET_PREVIEW, "int", 0, "int", 0);ferme le preview
DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SET_CALLBACK_FRAME, "int", 0, "int", 0);ajout
DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_END, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
;~ DllClose($avicap);ajout
DllClose($user)
if @error Then
return 0
Else
return 1
EndIf
EndFunc
;===============================================================================
;
; Description: Starts recording the webcam to a file
; Syntax: _WebcamRecordStart($sFile, $sId)
; Parameter(s): $sId - Id (returned from _WebcamOpen)
; $sFile - File to save the movie to (*.avi)
; Requirement(s): A webcam
; Return Value(s): On Success - Returns 1
; On Failure - Returns 0
; Author(s): Ludocus
; Note(s): Stop recording by: _WebcamRecordStop($Id)
;
;===============================================================================
Func _WebcamRecordStart($sFile, $sId)
DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_FILE_SET_CAPTURE_FILEA, "int", 0, "str", $sFile)
DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SEQUENCE, "int", 0, "int", 0)
if @error Then
return 0
Else
return 1
EndIf
EndFunc
[/autoit] [autoit][/autoit] [autoit];===============================================================================
;
; Description: Stops recording.
; Syntax: _WebcamRecordStop($sId)
; Parameter(s): $sId - Id (returned from _WebcamOpen)
; Requirement(s): A webcam
; Return Value(s): On Success - Returns 1
; On Failure - Returns 0
; Author(s): Ludocus
; Note(s): None
;
;===============================================================================
Func _WebcamRecordStop($sId)
DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_STOP, "int", 0, "int", 0)
if @error Then
return 0
Else
return 1
EndIf
EndFunc