#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: autoBert http://www.autoit.de/index.php?page=Thread&postID=182937#post182937 based on http://www.autoitscript.com/forum/index.php?showtopic=79366&view=findpost&p=572154 Script Function: Demo for Webcam Udf #ce ---------------------------------------------------------------------------- #include 'webcam.au3' #include #Include #include $cam_xlength = 640;Breite $cam_ylength = 480 ;Höhe $sProgTitel ="SnapShot from WebCam" $sProgVer = "v 0.8.1.3" $capDir = @ScriptDir & "\captures" If Not FileExists($capDir) Then DirCreate($capDir) HotKeySet("{INSERT}", "SnapShot") If _Singleton($sProgTitel & $sProgVer, 1) = 0 Then WinActivate($sProgTitel & $sProgVer) Exit EndIf $gui = GUICreate($sProgTitel & $sProgVer, $cam_xlength, $cam_ylength + 20, 0, 0) $WebcamID = _WebcamOpen($gui, 0, 0, $cam_xlength + 30, $cam_ylength) if $WebcamID = -1 Then MsgBox(16,"Fehler","WebCam kann nicht initialisiert werden!") exit EndIf $label1 = GUICtrlCreateLabel("", 0, $cam_ylength + 5, $cam_xlength, 20) _GDIPlus_Startup() GUISetState(@SW_SHOW) AdlibRegister("SnapShot", 10000) Do Until GUIGetMsg() = -3 AdlibUnRegister("SnapShot") _WebcamClose($WebcamID) ConsoleWrite($WebcamID& @CRLF) _GDIPlus_Shutdown() Func SnapShot() $nr = 1 While FileExists($capDir & "\Bild" & $nr & ".jpg") $nr += 1 WEnd $oFile = $capDir & "\Bild.bmp" $nFile = $capDir & "\Bild" & $nr & ".jpg" if FileExists($oFile) Then FileDelete($oFile) _WebcamSnap($WebcamID, $oFile) Local $aDT = FileGetTime($oFile) $sInfo = $aDT[0] & "/" & $aDT[1] & "/" & $aDT[2] & " " & $aDT[3] & ":" & $aDT[4] & ":" & $aDT[5] ConsoleWrite($sInfo & @CRLF) $himg = _GDIPlus_ImageLoadFromFile($oFile) $hGraphics = _GDIPlus_ImageGetGraphicsContext($himg) $iX = _GDIPlus_ImageGetWidth($himg) $iy = _GDIPlus_ImageGetHeight($himg) $hBrush = _GDIPlus_BrushCreateSolid(); $Color) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 20, 2) $tLayout = _GDIPlus_RectFCreate($iX -260, $iy -30) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sInfo, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphics, $sInfo, $hFont, $aInfo[0], $hFormat, $hBrush) _GDIPlus_GraphicsDrawImage($hGraphics, $himg, $iX, $iy) _GDIPlus_ImageSaveToFile($himg, $nFile) _GDIPlus_FontDispose($hFont) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_ImageDispose($himg) GUICtrlSetData($label1, $nr) FileDelete($oFile) EndFunc ;==>SnapShot