Sign in to follow this  
Followers 0
aphesia

No screenshots with webcam.au3

8 posts in this topic

#1 ·  Posted (edited)

THIS SCRIPT WILL LOCK THE COMPUTER JUST LIKE WIN + L DOES... PW = 1234

Webcam-Lock.au3 added 2 posts below

When trying to run my old script (which worked just fine some months ago and i didnt touch it in the meantime)

#include <GUIConstants.au3>
#Include <Misc.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Webcam.au3>
#Include <File.au3>
#Include <Array.au3>
#include <Timers.au3>
#NoTrayIcon


;bei spam 10sek blockinput + popup 
;clear shots folder
;dsplay off after 10 minutes.. propably programm which will start lock.exe after 30 minutes inactivity (kino.to fix?)
;disable alt + ctrl and stuff with if send then BlockInput

;Block ALt+F4 , ALT+TAB, WIN+D
HotKeySet("!{F4}","nicetry")
HotKeySet("!{D}","nicetry")
HotKeySet("!{TAB}","nicetry")

;Block cmd + .bat + taskmanager via registry
RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System", "DisableCMD", "REG_DWORD", "01")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", "01")

;parameters
$label = 30
$pic = 0
$save = 1
$gui = GUICreate("")
$webcam = _Webcam($gui, 0, 0, 320, 240)
$pic = "lal"
$labelpic = "lala"
$saved1 = "1"
$versuche = 0

;monitor off function
Func Monitor($io_control = "on")
   Local $WM_SYSCommand = 274
   Local $SC_MonitorPower = 61808
   Local $iState = 2
   Local $HWND = WinGetHandle("Program Manager")
   If $io_control = "on" Then $iState = -1
   DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", _
         $WM_SYSCommand, "int", $SC_MonitorPower, "int", $iState)
EndFunc   ;<==> Monitor()

;password read
;$file1 = "password.txt"
;$pw = FileRead($file1)
$pw = "1234"

;Create GUI
$Form1_1 = GUICreate("Locked", 1681, 1080, -1, -1)
$Group1 = GUICtrlCreateGroup("Unlock", 649, 465, 385, 217)
$Input1 = GUICtrlCreateInput("", 672, 576, 337, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL,$WS_EX_TOPMOST))
$Label1 = GUICtrlCreateLabel("Wrong password entry will be logged !!", 720, 528, 250, 17)
$Button1 = GUICtrlCreateButton("OK", 776, 632, 137, 33, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
;dont know if this rly helps
WinSetOnTop( "Locked" , "" , 1 )

;programm itself
While 1

;dont know if this rly helps
WinSetOnTop( "Locked" , "" , 1 )

;bye bye task manager + minimize
    If ProcessExists("taskmgr.exe") or WinExists("Windows Task Manager") or WinActive("Locked") = 0 Then
        winClose("Windows Task Manager")
        ProcessClose("taskmgr.exe")
        WinActivate("Locked")
    EndIf

;display off after 10 sec inactivity    
    If _Timer_GetIdleTime() > "10000" Then
            Monitor("off")              
    EndIf

;button + pw check + webcam-shots check
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Button1
        If GUICtrlRead($input1)=$pw Then    
                RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System", "DisableCMD", "REG_DWORD", "00")
                RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", "00")
                ExitLoop
        Else
                $versuche1 = $versuche + 1
                $versuche = $versuche1
                Local $avArray = _FileListToArray(@ScriptDir & "\shots\")
                $number = _ArrayMaxIndex($avArray, 0, 1)
                $number1 = $number+1
                $common = '.jpg'
                $jpg = $number1 & $common
                _WebcamSnap($webcam,@ScriptDir & "\shots\" & $jpg)
                If $pic <> 1 Then
                    $pic = GUICtrlCreatePic(@ScriptDir & "\shots\" & $jpg, 70, 90, 537, 381, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
                    $labelpic = GUICtrlCreateGroup("Hello :D", 48, 72, 580, 415)
                    $pic = 1
                EndIf
                if $versuche = 3 Then
                    GUICtrlDelete($label1)
                    $Label3 = GUICtrlCreateLabel("You failed 3 times... epic ! Notification sent via SMS.", 720, 528, 250, 17)
                    guictrldelete($button1)
                    $Button3 = GUICtrlCreateButton("Complete lock activated", 776, 632, 137, 33, 0)
                    BlockInput(1)
                    sleep(30000)
                    Blockinput(0)
                EndIf                               
                $saved = $saved1
                $saved1 = $saved1+1
                GUICtrlDelete( $save )
                $save = GUICtrlCreateLabel("Total pictures saved: " & $saved, 720, 600, 250, 17)
        EndIf
        
    EndSwitch
WEnd

Func nicetry()
EndFunc

it doesnt make any screens when i enter a wrong password. It shows a pop up for selecting the webcam device (which i didnt had in the past and which is quite annoying for my usage) but the screens are empty. Also run it as admin if you want to try it out.

Edited by aphesia

Share this post


Link to post
Share on other sites



Well that taught me that I must read posted code before running it. I just lost half an hours worth of unsaved work. You could have warned people trying to help you that running your script would lock them out of their PC.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

Sound like a possible misplaced "#include statement inside function" case. Check that Webcam.au3 file.

I just lost half an hours worth of unsaved work. You could have warned people trying to help you that running your script would lock them out of their PC.

Never-test run something while you have some unsaved files open. Besides where did you get that Webcam.au3 UFD. Its not a default AutoIt UDF and its not included here either, Ergo: Incomplete code -> Don't run it unless you know your ok with some potential trouble. (Of just VirtualBox it ... )

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

oh lol.. sorry for you beeing locked out of the system... i thought it would be clear what this script does when you jsut read some lines of it :unsure:

so for all: This is a script to lock the computer (e.g. you have a laptop and want to prevent anyone from doing something on it.. like win + L.. but this also makes webcamscreenshots when someone enters a wrong pw).

this is the webcam.udf i use:

#include <WindowsConstants.au3>
#include-once
$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")

;===============================================================================
;
; Description:      Open's a webcam preview screen in your gui
; Syntax:           _WebcamOpen($sHwnd, $sLeft, $sTop, $sWidth, $sHeight, $sPort=0)
; 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
;                   $sPort     - Specify wich webcam port you want to use (for multiple webcams)
; Requirement(s):   A webcam
; Return Value(s):  On Success - Returns id needed for other controls
;                   On Failure - Returns -1
; Author(s):        Ludocus
; Note(s):          If a black/blank screen shows up, try using different $sPort's (0 to 3)
;
;===============================================================================
Func _WebcamOpen($sHwnd, $sLeft, $sTop, $sWidth, $sHeight, $sPort=0)
    $cap = DllCall($avi, "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", $sPort, "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_END, "int", 0, "int", 0)
    DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
    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

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

@edit: okay there was the endfunc missing in the webcam.au3 .. thanks

btw if you dont run it as admin you can simply press "win" key + right click in start menu and then kill window.

Also: It somehow doesnt make webcam screens anymore (win7 x64). It asks me to choose my webcam device when i run it.. but there wont be any screens.

Edited by aphesia

Share this post


Link to post
Share on other sites

... and this is where the EndFunc is missing (webcam.au3 above, last line)


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

And maybe change the title too. As File.au3 doesn't appear to be missing any code.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

edited title + text since i have a new problem now :unsure:

thanks

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