Jump to content

joystickus

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by joystickus

  1. Got it! Thanks to everyone for help and remarks! The solution was in the part I missed: Func _MD5ForFile($sFile) Local $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFileW", _ "wstr", $sFile, _ "dword", 0x80000000, _ ; GENERIC_READ "dword", 1, _ ; FILE_SHARE_READ "ptr", 0, _ "dword", 3, _ ; OPEN_EXISTING "dword", 0, _ ; SECURITY_ANONYMOUS "ptr", 0) If @error Or $a_hCall[0] = -1 Then Return SetError(1, 0, "") EndIf Local $hFile = $a_hCall[0] $a_hCall = DllCall("kernel32.dll", "ptr", "CreateFileMappingW", _ "hwnd", $hFile, _ "dword", 0, _ ; default security descriptor "dword", 2, _ ; PAGE_READONLY "dword", 0, _ "dword", 0, _ "ptr", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Return SetError(2, 0, "") EndIf DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Local $hFileMappingObject = $a_hCall[0] $a_hCall = DllCall("kernel32.dll", "ptr", "MapViewOfFile", _ "hwnd", $hFileMappingObject, _ "dword", 4, _ ; FILE_MAP_READ "dword", 0, _ "dword", 0, _ "dword", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(3, 0, "") EndIf Local $pFile = $a_hCall[0] Local $iBufferSize = FileGetSize($sFile) Local $tMD5_CTX = DllStructCreate("dword i[2];" & _ "dword buf[4];" & _ "ubyte in[64];" & _ "ubyte digest[16]") DllCall("advapi32.dll", "none", "MD5Init", "ptr", DllStructGetPtr($tMD5_CTX)) If @error Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(4, 0, "") EndIf DllCall("advapi32.dll", "none", "MD5Update", _ "ptr", DllStructGetPtr($tMD5_CTX), _ "ptr", $pFile, _ "dword", $iBufferSize) If @error Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(5, 0, "") EndIf DllCall("advapi32.dll", "none", "MD5Final", "ptr", DllStructGetPtr($tMD5_CTX)) If @error Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(6, 0, "") EndIf DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Local $sMD5 = Hex(DllStructGetData($tMD5_CTX, "digest")) Return SetError(0, 0, $sMD5) EndFunc ;==>_MD5ForFile I didn't understand a single word in it, but once called it does what's needed.
  2. Update: I found half a solution -- comparing an MD5 sum. For my templates they're all unique and they do match nicely to the MD5's of screenshots. Only now I don't understand why in the script it doesn't work. If _IdenticalImages("2c.bmp","2d.bmp") Then MsgBox(64,"Info","Match") Else MsgBox(64,"Info","Don't match") EndIf Func _IdenticalImages($file1,$file2) If _MD5ForFile($file1) = _MD5ForFile($file2) Then Return True Else Return False EndIf EndFunc And it gives an error message: Line 8 If _MD5ForFile($file1) = _MD5ForFile($file2) Then If ^ ERROR Error: Unknown function name.
  3. 2Zedna Unfortunately I didn't manage to find anything like this in the forum. There are examples of comparing pictures pixel by pixel but I assumed that's not exactly what I need. I need it more simple -- to find out how to put binaries of the files into variables. 2Blue_Drache No, it's not anti-captcha. I want to use it as a trigger to making a click in two or more areas in the screen. Meaning if the picture in the given area is for example a green circle then click in the area one, if it's not then click in the area two.
  4. Greetings, Dear Members! Foreword: I am completely new to any kind of programming and this is my first experience both with AutoIt and programming. Overall task I need: to compare a certain area of the screen with a given template for two states -- identical or not. Here my thoughts: I made a template in a lossless format 24-bit bmp (size 12*27px). Then I can make a script to capture the same area from the screen to a temp file next to the template. And then I can compare them in their binary data and to see if it is identical of not. (When done by hands -- it gives pure picture with no mistakes.) In more details as I see it: I need to get the binary data of the template to a variable, then to capture the same area from the screen, to save it to a temp file and to get the binary data of the temp file to another variable. Then to compare those variables and go forward by one of the two ways depending on whether they are identical of not. Skipping a step would be to get the binary data to a second variable (from the screen) directly from the buffer when the area is captured. And here's a problem: I didn't manage to find the way in AutoIt to get the binary data of the *.bmp file to a variable and/or from the buffer. Can you please give me a hint of the operators I need to use to do that simple task? Thank you for your attention.
×
×
  • Create New...