Sign in to follow this  
Followers 0
Skrip

Can't figure out why it won't take..webcam..picture..

2 posts in this topic

I'm trying to make it so it will take a screen shot if you get pass wrong (btw pass is 1-2-5-7-9) And it won't take the shot. Please review and explain.

#region Webcam
#include <GuiConstants.au3>
$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
$avi = DllOpen("avicap32.dll")
$user = DllOpen("user32.dll")
$snapfile = @ScriptDir & "\scrshot.bmp"

$Main = GUICreate("Camera",1,1)
$cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", 1, "int", 1, "int", 1, "int", 1, "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)
#endregion Webcam



#region -Hotkeys
HotKeySet("1", "a1")
HotKeySet("2", "a2")
HotKeySet("3", "a3")
HotKeySet("4", "a4")
HotKeySet("5", "a5")
HotKeySet("6", "a6")
HotKeySet("7", "a7")
HotKeySet("8", "a8")
HotKeySet("9", "a9")
HotKeySet("{ENTER}", "enter_h")
#endregion -Hotkeys

#region --- GuiBuilder code Start ---
SoundPlay("C:\Windows\media\chord.wav")
#NoTrayIcon
; Script generated by AutoBuilder 0.5 Prototype
#include <File.au3>
#include <date.au3>
$returnvalue = _DateDayOfWeek(@WDAY, 0 )
_FileWriteLog("C:\Pass\Logs\Log_Pass.dat", " ")
_FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "-------------------")
_FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "---Script Activated " & $returnvalue)
_FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "-------------------")
_FileWriteLog("C:\Pass\Logs\Log_Pass.dat", " ")
AutoItSetOption("GUIResizeMode", 0)
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("Password", 1600, 2200, 0, 0, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)
Dim $ATTEMPT = 0
$shut = GUICtrlCreateButton("Shutdown", 550, 360, 100, 30)
$label = GUICtrlCreateLabel("Please enter security password for this computer.", 490, 400)
$Button_1 = GuiCtrlCreateButton("1", 540, 430, 40, 40)
$Button_2 = GuiCtrlCreateButton("2", 580, 430, 40, 40)
$Button_3 = GuiCtrlCreateButton("3", 620, 430, 40, 40)
$Button_4 = GuiCtrlCreateButton("4", 540, 470, 40, 40)
$Button_5 = GuiCtrlCreateButton("5", 580, 470, 40, 40)
$Button_6 = GuiCtrlCreateButton("6", 620, 470, 40, 40)
$Button_7 = GuiCtrlCreateButton("7", 540, 510, 40, 40)
$Button_8 = GuiCtrlCreateButton("8", 580, 510, 40, 40)
$Button_9 = GuiCtrlCreateButton("9", 620, 510, 40, 40)
$Button_10 = GuiCtrlCreateButton("Enter", 540, 550, 120, 30)
$Date_1 = GuiCtrlCreateDate("Date1", 510, 330, 190, 20)
AutoItSetOption("WinTitleMatchMode", 2)
$win_name = "Picture"
$pass = 0
$pass2 = 0
$shutdown = 1
GUISetBkColor(0xfaebd7)
WinActivate("Password")
GuiSetState()


While 1
   ;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)
    Sleep(1)
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $shut;shutdown button
        If $shutdown = 1 Then; only activates once with this added!
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "--Shutdown Key Pressed--" & $ATTEMPT & " -" & $returnvalue)
            GuiCtrlSetData($Button_1, GetToggle1(GuiCtrlRead($Button_1)))
            GuiCtrlSetData($Button_2, GetToggle2(GuiCtrlRead($Button_2)))
            GuiCtrlSetData($Button_3, GetToggle3(GuiCtrlRead($Button_3)))
            GuiCtrlSetData($Button_4, GetToggle4(GuiCtrlRead($Button_4)))
            GuiCtrlSetData($Button_5, GetToggle5(GuiCtrlRead($Button_5)))
            GuiCtrlSetData($Button_6, GetToggle6(GuiCtrlRead($Button_6)))
            GuiCtrlSetData($Button_7, GetToggle7(GuiCtrlRead($Button_7)))
            GuiCtrlSetData($Button_8, GetToggle8(GuiCtrlRead($Button_8)))
            GuiCtrlSetData($Button_9, GetToggle9(GuiCtrlRead($Button_9)))
            GuiCtrlSetData($Button_10, GetToggle10(GuiCtrlRead($Button_10)))
            GUISetBkColor(0x27408B)
            Sleep(100)
            GUISetBkColor(0x3A5FCD)
            Sleep(100)
            GUISetBkColor(0x436EEE)
            Sleep(100)
            GUISetBkColor(0x4876FF)
            Sleep(100)
            GUISetBkColor(0xffffff)
            Sleep(100)
            GUISetBkColor(0x000000)
            Sleep(1600)
            $shutdown = 0
            Shutdown(13)
        EndIf
    
    Case $msg =  $Button_1
        If $pass = 0 Then
            $pass = 1
        EndIf
    Case $msg = $Button_2
        If $pass = 1 Then
            $pass = 2
        EndIf
    Case $msg = $Button_3
        $pass = 0
    Case $msg = $Button_4
        $pass = 0
    Case $msg = $Button_5
        IF $pass = 2 Then
            $pass = 3
        EndIf
    Case $msg = $Button_6
        $pass = 0
    Case $msg = $Button_7
        IF $pass = 3 Then
            $pass = 4
        EndIf
    Case $msg = $Button_8
        $pass = 0
    Case $msg = $Button_9
        IF $pass = 4 Then
            $pass = 5
        EndIf
    Case $msg = $Button_10; Code -- pass = 5;; 1-2-5-7-9
    ; -- ENTER KEY --
        If $pass = 5 Then
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", " ")
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "*_-=Pass Accepted=-_* " & $ATTEMPT & " -" & $returnvalue)
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", " ")
            SoundPlay("C:\Windows\media\tada.wav")
            ProcessClose("ImgStud.exe")
            Sleep(1200)
            Exit
        EndIf
        If $pass = 0 Then
            $ATTEMPT = $ATTEMPT + 1
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "*** Invalid Pass *** " & $ATTEMPT & " -" & $returnvalue)
            Send("{VOLUME_MUTE}")
            WinWaitActive("ImageStudio", "", 2)
            ControlClick("ImageStudio", "Take a &Picture", 1000)
            Sleep(600)
            Send("{VOLUME_MUTE}")
            If WinExists($win_name) Then
                WinClose($win_name)
            EndIf
            WinActivate("Password")
            SoundPlay("C:\Windows\media\Windows XP Error.wav")
            SnapShot()
        EndIf
        If $pass = 1 Then
            $ATTEMPT = $ATTEMPT + 1
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "*** Invalid Pass *** " & $ATTEMPT & " -" & $returnvalue)
            Send("{VOLUME_MUTE}")
            WinWaitActive("ImageStudio", "", 2)
            ControlClick("ImageStudio", "Take a &Picture", 1000)
            Sleep(600)
            Send("{VOLUME_MUTE}")
            If WinExists($win_name) Then
                WinClose($win_name)
            EndIf
            WinActivate("Password")
            SoundPlay("C:\Windows\media\Windows XP Error.wav")
            SnapShot()
        EndIf
        If $pass = 2 Then
            $ATTEMPT = $ATTEMPT + 1
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "*** Invalid Pass *** " & $ATTEMPT & " -" & $returnvalue)
            Send("{VOLUME_MUTE}")
            WinWaitActive("ImageStudio", "", 2)
            ControlClick("ImageStudio", "Take a &Picture", 1000)
            Sleep(600)
            Send("{VOLUME_MUTE}")
            If WinExists($win_name) Then
                WinClose($win_name)
            EndIf
            WinActivate("Password")
            SoundPlay("C:\Windows\media\Windows XP Error.wav")
            SnapShot()
        EndIf
        If $pass = 3 Then
            $ATTEMPT = $ATTEMPT + 1
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "*** Invalid Pass *** " & $ATTEMPT & " -" & $returnvalue)
            Send("{VOLUME_MUTE}")
            WinWaitActive("ImageStudio", "", 2)
            ControlClick("ImageStudio", "Take a &Picture", 1000)
            Sleep(600)
            Send("{VOLUME_MUTE}")
            If WinExists($win_name) Then
                WinClose($win_name)
            EndIf
            WinActivate("Password")
            SoundPlay("C:\Windows\media\Windows XP Error.wav")
            SnapShot()
        EndIf
        If $pass = 4 Then
            $ATTEMPT = $ATTEMPT + 1
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "*** Invalid Pass *** " & $ATTEMPT & " -" & $returnvalue)
            Send("{VOLUME_MUTE}")
            WinWaitActive("ImageStudio", "", 2)
            ControlClick("ImageStudio", "Take a &Picture", 1000)
            Sleep(600)
            Send("{VOLUME_MUTE}")
            If WinExists($win_name) Then
                WinClose($win_name)
            EndIf
            WinActivate("Password")
            SoundPlay("C:\Windows\media\Windows XP Error.wav")
            SnapShot()
        EndIf
        
        $pass = 0
        $ATTEMPT = $ATTEMPT + 1
        _FileWriteLog("C:\Pass\Logs\Log_Pass.dat""", "*** Invalid Pass ***  " & $ATTEMPT & " -" & $returnvalue)
            Send("{VOLUME_MUTE}")
            WinWaitActive("ImageStudio", "", 2)
            ControlClick("ImageStudio", "Take a &Picture", 1000)
            Sleep(600)
            Send("{VOLUME_MUTE}")
            If WinExists($win_name) Then
                WinClose($win_name)
            EndIf
            WinActivate("Password")
            SnapShot()
    EndSelect
WEnd
Exit
#endregion --- GuiBuilder generated code End ---

#region -Shutdown funcs
;;; Text toggles 1-9-enter for the shutdown button
Func GetToggle1($stext)
if $stext = "1" then
return " "
else
return "1"
endif
endfunc
Func GetToggle2($stext)
if $stext = "2" then
return " "
else
return "2"
endif
endfunc
Func GetToggle3($stext)
if $stext = "3" then
return " "
else
return "3"
endif
endfunc
Func GetToggle4($stext)
if $stext = "4" then
return " "
else
return "4"
endif
endfunc
Func GetToggle5($stext)
if $stext = "5" then
return " "
else
return "5"
endif
endfunc
Func GetToggle6($stext)
if $stext = "6" then
return " "
else
return "6"
endif
endfunc
Func GetToggle7($stext)
if $stext = "7" then
return " "
else
return "7"
endif
endfunc
Func GetToggle8($stext)
if $stext = "8" then
return " "
else
return "8"
endif
endfunc
Func GetToggle9($stext)
if $stext = "9" then
return " "
else
return "9"
endif
endfunc
Func GetToggle10($stext)
if $stext = "Enter" then
return "Shuting Down..."
else
return "Enter"
endif
endfunc
Func GetToggle11($stext)
if $stext = "Shutdown" then
return "Denied! This button has been pressed."
else
return "Shutdown"
endif
endfunc
#endregion -Shutdown funcs

#region -HotKey Funcs
Func a1()
    If $pass = 0 Then
        $pass = 1
    EndIf
EndFunc
Func a2()
    If $pass = 1 Then
        $pass = 2
    EndIf
EndFunc
Func a3()
    $pass = 0
EndFunc
Func a4()
    $pass = 0
EndFunc
func a5()
    IF $pass = 2 Then
        $pass = 3
    EndIf
EndFunc
Func a6()
    $pass = 0
EndFunc
Func a7()
    IF $pass = 3 Then
        $pass = 4
    EndIf
EndFunc
Func a8()
    $pass = 0
EndFunc
Func a9()
    IF $pass = 4 Then
        $pass = 5
    EndIf
EndFunc
Func enter_h()
    ; -- ENTER KEY --
        If $pass = 5 Then
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", " ")
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "*_-=Pass Accepted=-_* -HotKeyused- " & $ATTEMPT & " -" & $returnvalue)
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", " ")
            SoundPlay("C:\Windows\media\tada.wav")
            Sleep(1200)
            Exit
        EndIf
        If $pass = 0 Then
            $ATTEMPT = $ATTEMPT + 1
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "*** Invalid Pass ***-HotKeyused-  " & $ATTEMPT & " -" & $returnvalue)
            SoundPlay("C:\Windows\media\Windows XP Error.wav")
            SnapShot()
        EndIf
        If $pass = 1 Then
            $ATTEMPT = $ATTEMPT + 1
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "*** Invalid Pass ***-HotKeyused-  " & $ATTEMPT & " -" & $returnvalue)
            SoundPlay("C:\Windows\media\Windows XP Error.wav")
            SnapShot()
        EndIf
        If $pass = 2 Then
            $ATTEMPT = $ATTEMPT + 1
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "*** Invalid Pass ***-HotKeyused-  " & $ATTEMPT & " -" & $returnvalue)
            SoundPlay("C:\Windows\media\Windows XP Error.wav")
            SnapShot()
        EndIf
        If $pass = 3 Then
            $ATTEMPT = $ATTEMPT + 1
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "*** Invalid Pass ***-HotKeyused-  " & $ATTEMPT & " -" & $returnvalue)
            SoundPlay("C:\Windows\media\Windows XP Error.wav")
            SnapShot()
        EndIf
        If $pass = 4 Then
            $ATTEMPT = $ATTEMPT + 1
            _FileWriteLog("C:\Pass\Logs\Log_Pass.dat", "*** Invalid Pass ***-HotKeyused-  " & $ATTEMPT & " -" & $returnvalue)
            SoundPlay("C:\Windows\media\Windows XP Error.wav")
            SnapShot()
        EndIf
        SnapShot()
        $pass = 0
        $ATTEMPT = $ATTEMPT + 1
        _FileWriteLog("C:\Pass\Logs\Log_CC.dat""", "*** Invalid Pass ***-HotKeyused-   " & $ATTEMPT & " -" & $returnvalue)
EndFunc
#endregion -HotKey Funcs

#region -Misc. Funcs
Func SECURE();; Unused;;
    WinMinimizeAll()
    Run("taskmgr.exe", "", @SW_DISABLE)
EndFunc ;==>SECURE

Func IMGSTUD()
    $folder = "C:\Program Files\Logitech\ImageStudio\"
    $file = FileGetShortName("C:\Program Files\Logitech\ImageStudio\ImgStud.exe")
    WinActivate("Password")
    Run($file, $folder)
    WinActivate("Password")
    GUISetBkColor(0xffffff)
EndFunc

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

#endregion -Misc. Funcs

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites



Anybody know? it can't be that hard...


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

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