Jump to content

PixelChecksum + coordinates ??


cutprod
 Share

Recommended Posts

Hello everyone,

I have a UDF that displays a webcam in a Gui =

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.11.7 (beta)
    Author:         Ludocus
    Modified for four webcams by pierrotm777, some corrections by Matwachich
    Script Function: Multi Webcam Udf
    
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include-once

; ##### Constants #####
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
; #####################################################################
; For description of all these constants, see
; http://msdn.microsoft.com/en-us/library/dd743599(v=VS.85).aspx
; #####################################################################

Global $WM_CAP_AVI_DLL = DllOpen("avicap32.dll")
Global $WM_CAP_USER_DLL = DllOpen("user32.dll")

;===============================================================================
;
; 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
;                   $WebCamId  - The capture driver to open
; Requirement(s):   A webcam
; Return Value(s):  On Success - Returns id needed for other controls ($sId)
;                   On Failure - Returns -1
; Author(s):        Ludocus
; Note(s):          None
;
;===============================================================================
Func _Webcam_Open($sHwnd, $sLeft, $sTop, $sWidth, $sHeight, $WebCamId = 0)
    Local $cap = DllCall($WM_CAP_AVI_DLL, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD, $WS_VISIBLE), "int", $sLeft, "int", $sTop, "int", $sWidth, "int", $sHeight, "hwnd", $sHwnd, "int", 1)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", $WebCamId, "int", 0)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0)
    If @error Then Return -1
    Return $cap[0]
EndFunc   ;==>_Webcam_Open

Func _Webcam_Preview_Start($sId, $iFPS = 15) ; $iFPS = Refresh frequency of the screen in Hertz (not Frame Per Seconde , See in MSDN)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SET_PREVIEWRATE, "int", $iFPS, "int", 0)
EndFunc   ;==>_Webcam_Preview_Start

Func _Webcam_Preview_Stop($sId)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SET_PREVIEW, "int", 0, "int", 0)
EndFunc   ;==>_Webcam_Preview_Stop

;===============================================================================
;
; Description:      Used to send configuration messages to the webcam capture control
; Syntax:           _Webcam_Settings($sId, $Settings, $iFirstParam = 1, $iSecParam = 0)
; Parameter(s):     $sId       - Id (returned from _Webcam_Open)
;                   $Settings (compression,display,format,source)
;                               $WM_CAP_DLG_VIDEOCOMPRESSION
;                               $WM_CAP_DLG_VIDEODISPLAY
;                               $WM_CAP_DLG_VIDEOFORMAT
;                               $WM_CAP_DLG_VIDEOSOURCE
;                           - These four keywords open config dialog, if you use theme,
;                                   et the other param at default value
;                           - You can use this function to send any other Constants listed above
;                   $iFirstParam and $iSecParam - Parameters of the message (see MSDN, the link above)
; Requirement(s):   A webcam
; Return Value(s):  On Success - Returns 1
;                   On Failure - Returns 0
; Author(s):        Ludocus
; Note(s):          None
;
;===============================================================================
Func _Webcam_Settings($sId, $Settings, $iFirstParam = 1, $iSecParam = 0)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $Settings, "int", $iFirstParam, "int", $iSecParam)
    If @error Then Return -1
    Return 1
EndFunc   ;==>_Webcam_Settings


;===============================================================================
;
; Description:      Creates a Snapshot from a webcam
; Syntax:           _WebcamSnap($sId, $sFile)
; Parameter(s):     $sId       - Id (returned from _Webcam_Open)
;                   $sFile     - File to save the snapshot to (*.bmp or *.jpg)
; Requirement(s):   A webcam
; Return Value(s):  On Success - Returns 1
;                   On Failure - Returns 0
; Author(s):        Ludocus
; Note(s):          None
;
;===============================================================================
Func _Webcam_Snap($sId, $sFile)
    Local $convert = False, $closeGDI = False
    If StringRight($sFile, 4) = ".jpg" Then
        Local $file_final = $sFile
        $sFile = StringTrimRight($sFile, 3) & "bmp"
        $convert = True
    EndIf
    ;   DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SET_CALLBACK_FRAME, "int", 0, "int", 0)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $sFile)
    If FileGetSize($sFile) = 0 Then
        FileDelete($sFile)
        Return 0
    EndIf
    If $convert Then
        If $ghGDIPDll = 0 Then
            _GDIPlus_Startup()
            $closeGDI = True
        EndIf
        Local $img = _GDIPlus_ImageLoadFromFile($sFile)
        _GDIPlus_ImageSaveToFile($img, $file_final)
        _GDIPlus_ImageDispose($img)
        If $closeGDI Then _GDIPlus_Shutdown()
        FileDelete($sFile)
    EndIf
    If @error Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc   ;==>_Webcam_Snap

;===============================================================================
;
; Description:      Closes the preview screen created with _Webcam_Open
; Syntax:           _WebcamClose($sId)
; Parameter(s):     $sId       - Id (returned from _Webcam_Open)
; Requirement(s):   A webcam
; Return Value(s):  On Success - Returns 1
;                   On Failure - Returns 0
; Author(s):        Ludocus
; Note(s):          None
;
;===============================================================================
Func _Webcam_Close($sId)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SET_PREVIEW, "int", 0, "int", 0);ferme le preview
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SET_CALLBACK_FRAME, "int", 0, "int", 0);ajout
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_END, "int", 0, "int", 0)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
    If @error Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc   ;==>_Webcam_Close

;===============================================================================
;
; Description:      Starts recording the webcam to a file
; Syntax:           _WebcamRecordStart($sFile, $sId)
; Parameter(s):     $sId       - Id (returned from _Webcam_Open)
;                   $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 _Webcam_Rec_Start($sFile, $sId)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_FILE_SET_CAPTURE_FILEA, "int", 0, "str", $sFile)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SEQUENCE, "int", 0, "int", 0)
    If @error Then
        Return 0
    Else
        Return 1
    EndIf

EndFunc   ;==>_Webcam_Rec_Start

;===============================================================================
;
; Description:      Stops recording.
; Syntax:           _WebcamRecordStop($sId)
; Parameter(s):     $sId       - Id (returned from _Webcam_Open)
; Requirement(s):   A webcam
; Return Value(s):  On Success - Returns 1
;                   On Failure - Returns 0
; Author(s):        Ludocus
; Note(s):          None
;
;===============================================================================
Func _Webcam_Rec_Stop($sId)
    DllCall($WM_CAP_USER_DLL, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_STOP, "int", 0, "int", 0)
    If @error Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc   ;==>_Webcam_Rec_Stop

I want to do that when an object or otherwise enters the fields of the webcam the cursor moves immediately above, and more (if possible) the follow!

Maybe I should have to post in "request to create ..." :x

If anyone can help me or guide me, thank you in advance.

sorry for the language ... I do not speak English well! :P

Edited by cutprod
Link to comment
Share on other sites

I find this post =

this script =

#include "array.au3"

Dim $Area[Ceiling((@DesktopHeight / 100) + 1)][Ceiling((@DesktopWidth / 100))]

$i = 0
$u = 0

For $x = 0 To @DesktopWidth Step 100
    For $y = 0 To @DesktopHeight Step 100
        $Area[$i][$u] = PixelChecksum($x, $y, $x + 99, $y + 99)
        $i += 1
    Next
    $u += 1
    $i = 0
Next

While 1
    For $u = 0 To UBound($Area, 2) - 1
        For $i = 0 To UBound($Area, 1) - 1
            If $Area[$i][$u] <> PixelChecksum($u * 100, $i * 100, $u * 100 + 99, $i * 100 + 99) Then
                MouseClick("main", ($u * 100), ($i * 100))
                MsgBox(0, "", ($u * 100) & ($i * 100))
            EndIf
        Next
    Next
WEnd

I think it corresponds to what I want, but I have trouble (I'm new to AutoIt) is to convert for my script =

(use with the above udf webcam.au3)

#include <Webcam.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 500, 400)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

HotKeySet("{F5}","close")


$cam = _Webcam_Open($Form1,10,10,480,380)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd


Func close()
    _Webcam_Close($cam)
    Exit
EndFunc

Can anyone help me?

Edited by cutprod
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...