michaelslamet Posted January 13, 2014 Share Posted January 13, 2014 I am taking few screenshots using: _ScreenCapture_CaptureWnd and then save it using: _ScreenCapture_SaveImage When the last 2 images are identical, my script will break the loop. The questions is how to verify that 2 images are identical? I was thinking using CRC32 to check the files checksum but my small experiment show that _ScreenCapture_SaveImage give a different file size for 2 same images. Link to comment Share on other sites More sharing options...
l3ill Posted January 13, 2014 Share Posted January 13, 2014 UEZ probably has a snippet lying around that will do it.. But if you want a head start this is what it looks like in VB I wish I had time to play with it.. :-( http://www.vbforums.com/showthread.php?6972-Determining-if-two-pictures-are-identical&p=1484338&viewfull=1#post1484338 Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
guinness Posted January 13, 2014 Share Posted January 13, 2014 I have a function that is laying around someone on the Forum to create a MD5 hash. If the filesize is different then the files aren't identical. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Geir1983 Posted January 13, 2014 Share Posted January 13, 2014 I use _ImageSearch (function found in this forum). Ccreate two HBITMAPs with _ScreenCapture_Capture and search for the first one in the second one. If the result is 1 they are identical. Link to comment Share on other sites More sharing options...
UEZ Posted January 13, 2014 Share Posted January 13, 2014 (edited) Try this: Not the fastest way to compare if you want to check a lot of images. Otherwise save the image, e.g. alwasy as BMP and compare it with MD5 if they have same size. If you want more information about the differencies than you have to compare pixel by pixel as done in the link above. Br, UEZ Edited January 13, 2014 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
michaelslamet Posted January 14, 2014 Author Share Posted January 14, 2014 Thanks all for reply and help @guinness: in fact, I've been using your _MD5Hash function for a while and found it very useful On my post #1, I said "my small experiment show that _ScreenCapture_SaveImage give a different file size for 2 same images". I think I found the problem: 1. I use _ScreenCapture_CaptureWnd with parameter "true" for the cursor, so it will capture the mouse pointer too. When the pointer moved, the result file (screenshot) will be different (obviously). 2. On the second capture, I activate the window again using WinActivate. Sometime (not always) this will give a different screenshot, maybe the title of the window flash or something like that. Anyway, here is the code: expandcollapse popup#include <ScreenCapture.au3> #include <Crypt.au3> $file1 = "c:\temp\ttt.png" $file2 = "c:\temp\sss.png" FileDelete($file1) FileDelete($file2) While NOT WinExists("[TITLE:Untitled - Notepad]") Run("notepad.exe") Sleep(100) WEnd $ActiveWindow = WinGetHandle("[TITLE:Untitled - Notepad]") WinActivate($ActiveWindow) $tmp = WinGetClientSize("[TITLE:Untitled - Notepad]") $Image = _ScreenCapture_CaptureWnd ("", $ActiveWindow, 0, 0, $tmp[0], $tmp[1]+200, false) _ScreenCapture_SaveImage ($file1, $Image, True) Sleep(2000) $tmp = WinGetClientSize("[TITLE:Untitled - Notepad]") $Image = _ScreenCapture_CaptureWnd ("", $ActiveWindow, 0, 0, $tmp[0], $tmp[1]+200, false) _ScreenCapture_SaveImage ($file2, $Image, True) If _MD5Hash($file1,100) = _MD5Hash($file2,100) Then MsgBox(0, "", "Filesize of file1 = " & FileGetSize($file1) & @CRLF & "Filesize of file2 = " & FileGetSize($file2) & @CRLF & "File is identical") Else MsgBox(0, "", "Filesize of file1 = " & FileGetSize($file1) & @CRLF & "Filesize of file2 = " & FileGetSize($file2) & @CRLF & "File is NOT identical!!") EndIf ; By guinness - 2012-2013. Func _MD5Hash($sFilePath, $iPercentageRead = Default) ; Default is 100 percent. $iPercentageRead = Int($iPercentageRead) If ($iPercentageRead > 100) Or ($iPercentageRead < 0) Then $iPercentageRead = 100 EndIf Return _Crypt_HashData(FileRead($sFilePath, ($iPercentageRead / 100) * FileGetSize($sFilePath)), $CALG_MD5) EndFunc ;==>_MD5Hash Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now