Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/11/2023 in all areas

  1. I'll try again tomorrow and post full console log.
    1 point
  2. If you only want to check if two files are different then you can use the memcmp WinAPI function. ;Coded by UEZ build 2023-11-12 #include <WinAPIFiles.au3> #include <WinAPIHObj.au3> Global $fTimer = TimerInit() Global $bIsDifferent = FastBinCompare("TestPtrn_2_DEh.raw", "TestPtrn_1.raw") ConsoleWrite("Time: " & TimerDiff($fTimer) & " ms" & @CRLF) ConsoleWrite("Is different: " & $bIsDifferent & @CRLF) Func FastBinCompare($sFile1, $sFile2) Local $iFileSize = FileGetSize($sFile1) If $iFileSize <> FileGetSize($sFile2) Or Not $iFileSize Then Return SetError(1, -1, -1) Local $tBuffer1 = DllStructCreate("byte[" & $iFileSize & "]"), $tBuffer2 = DllStructCreate("byte[" & $iFileSize & "]") Local $hFile = _WinAPI_CreateFile($sFile1, 2, 2), $nBytes _WinAPI_ReadFile($hFile, $tBuffer1, $iFileSize, $nBytes) _WinAPI_CloseHandle($hFile) $hFile = _WinAPI_CreateFile($sFile2, 2, 2) _WinAPI_ReadFile($hFile, $tBuffer2, $iFileSize, $nBytes) _WinAPI_CloseHandle($hFile) Local $aResult = DllCall("msvcrt.dll", "int:cdecl", "memcmp", "struct*", $tBuffer1, "struct*", $tBuffer2, "uint", DllStructGetSize($tBuffer1)) If @error Or Not IsArray($aResult) Then Return SetError(2, -2, -2) Return $aResult[0] EndFunc Or here regarding image compare:
    1 point
  3. This might be true and it makes more sense now what @jchd said above.
    1 point
  4. Try this: #include <Memory.au3> $tFile1 = ReadBinaryFile('TestPtrn_2_DEh.raw') $tFile2 = ReadBinaryFile('TestPtrn_1.raw') $Init = TimerInit() $iMaxDiff = CompareData($tFile1, $tFile2) ConsoleWrite("MAX DIFF: " & $iMaxDiff & " digital level" & @CRLF) ConsoleWrite("Time: " & TimerDiff($Init) & " ms" & @CRLF) Func CompareData(Const ByRef $tFile1, Const ByRef $tFile2) Local $sCode = '0x8B7424048B7C24088B4C240C31D28A068A1F38D8770688C488D888E328D838D0720288C24647E2E689D0C20C00' Local $dCode = Binary($sCode) Local $iCodeSize = BinaryLen($dCode) Local $tBuffer = DllStructCreate('byte Code[' & $iCodeSize & ']') DllStructSetData($tBuffer, 'Code', $dCode) Local $aCall = DllCallAddress('int', DllStructGetPtr($tBuffer), 'ptr', DllStructGetPtr($tFile1), 'ptr', DllStructGetPtr($tFile2), 'int', DllStructGetSize($tFile1)) Return $aCall[0] EndFunc Func ReadBinaryFile($sPath) Local $iSize = FileGetSize($sPath) Local $tFile = DllStructCreate("byte Data[" & $iSize & "]") Local $hFile = FileOpen($sPath, 16) ; FO_READ + FO_BINARY $tFile.Data = FileRead($hFile) FileClose($hFile) Return $tFile EndFunc
    1 point
  5. All this doesn't seem to make sense (for me at least). If you specify reading as binary, all you get is a verbatim (binary) stream of bytes just like you could see using an hex file editor. Mixing file encoding parameters doesn't make sense. I suspect that the core function tries hard to be clever and does overwrite binary flag when ANSI or UTFx are also there, but this is nonsensical. At a restaurant, ask your meat both raw, blue, rare, medium and well done to watch the eyes of the embarrassed waiter. No, it reads the file as binary, verbatim from bytes from disc. A binary file has no encoding, zero, none, nada, ketchi. For instance a jpeg image uses a file format, but no encoding. That question remains yours! You are supposed to know your data and act consistantly: if you read in a .gif, correctly store it as a blob, are you really going to save back the bytes converted to UTF8? File encoding is a metadata and you'd have to handle that extra information by yourself to avoid breaking things down. Suppose I give you a text file without telling you which encoding it was used to create it (e.g. codepage 20905, turkish IBM EBCDIC), then you're unable to process it correctly or, rather, have very little chance of doing so! https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
    1 point
  6. If you are running x86 version of AutoIt this function will run in less than 1ms: $tFile1 = ReadBinaryFile('TestPtrn_1.raw') $tFile2 = ReadBinaryFile('TestPtrn_2.raw') $Init = TimerInit() $iMaxDiff = CompareData($tFile1, $tFile2) ConsoleWrite("MAX DIFF: " & $iMaxDiff & " digital level" & @CRLF) ConsoleWrite("Time: " & TimerDiff($Init) & " ms" & @CRLF) Func CompareData(Const ByRef $tFile1, Const ByRef $tFile2) Local $sCode = '0x8B7424048B7C24088B4C240C31D28A068A1F28D8780E38D07F064647E2F0EB0A88C2EBF62A1E88D8EBEC89D0C20C00' Local $dCode = Binary($sCode) Local $iCodeSize = BinaryLen($dCode) Local $tBuffer = DllStructCreate('byte Code[' & $iCodeSize & ']') DllStructSetData($tBuffer, 'Code', $dCode) Local $aCall = DllCallAddress('int', DllStructGetPtr($tBuffer), 'ptr', DllStructGetPtr($tFile1), 'ptr', DllStructGetPtr($tFile2), 'int', DllStructGetSize($tFile1)) Return $aCall[0] EndFunc Func ReadBinaryFile($sPath) Local $iSize = FileGetSize($sPath) Local $tFile = DllStructCreate("byte Data[" & $iSize & "]") Local $hFile = FileOpen($sPath, 16) ; FO_READ + FO_BINARY $tFile.Data = FileRead($hFile) FileClose($hFile) Return $tFile EndFunc
    1 point
  7. Andreik

    AutoIt Snippets

    I know but for some simple scripts I don't want to add more dependencies but to use native AutoIt functions and UDFs.
    1 point
  8. I didn't run the executable, I am more interested in code to work. Do you run the same code as it is on github? Unbalanced parentheses for example is a fatal error on every AutoIt version. Check Use_Inventory() function and confirm if you have this line: $mp = $PlayerMP + GetTok($code, "2", "43"))
    1 point
  9. We aim to please. You'd need to copy the Eigen4AutoIt.ini file (auto-generated when you first run E4A; edit it as you see fit) and the appropriate dll (EigenDense.dll for x86 or EigenDense_x64.dll for x64). Since your data files are tiny (no offense), you probably don't need the extra power that the x64 E4A environment provides, so just compile for x86 and copy EigenDense.dll locally. Note that the dll-path variable in the .ini file needs to point to where the dll resides. If you provide an installer for your package like InnoSetup, you can make it overwrite this path in the .ini file to wherever your installer places the other files during any user-defined local installation.
    1 point
  10. @RAMzor I get 15 ms on my crappy old laptop, with a little matrix magic: #include "Eigen4AutoIt.au3" $rows = 640 $cols = 512 $colsInt = 512/4 ; has to be divisible by four $elements = $rows * $cols _Eigen_StartUp("int") _Eigen_ResetLogicalBit0only() ; this means use all 32 bits when masking (do not reduce to true/false) ; create work buffers (do this once, prior to any number of file comparisons thereafter) $matA = _Eigen_CreateMatrix($rows, $colsInt) $refA = DllStructCreate("byte[" & $elements & "]", _Eigen_GetPtr($matA, "A", False, False)) $matAx4 = _Eigen_CreateMatrix($rows, $cols) $matB = _Eigen_CreateMatrix($rows, $colsInt) $refB = DllStructCreate("byte[" & $elements & "]", _Eigen_GetPtr($matB, "B", False, False)) $matBx4 = _Eigen_CreateMatrix($rows, $cols) Global $matMask = _Eigen_CreateMatrix_Constant($rows, $cols, 255) _Eigen_CwiseScalarOp_Block_InPlace ($matMask,0,$colsInt,$rows,$colsInt,"shl",8) _Eigen_CwiseScalarOp_Block_InPlace ($matMask,0,$colsInt*2,$rows,$colsInt,"shl",16) _Eigen_CwiseScalarOp_Block_InPlace ($matMask,0,$colsInt*3,$rows,$colsInt,"shl",24) ; file comparison starts here $sPath1 = "TestPtrn_1.raw" $sPath2 = "TestPtrn_2.raw" $hFileOpen = FileOpen($sPath1, BitOR($FO_READ, $FO_BINARY)) DllStructSetData($refA, 1, FileRead($hFileOpen)) FileClose($hFileOpen) $hFileOpen = FileOpen($sPath2, BitOR($FO_READ, $FO_BINARY)) DllStructSetData($refB, 1, FileRead($hFileOpen)) FileClose($hFileOpen) $t1 = TimerInit() ; with expansion _ExpandBytesToInt32($matA, $matAx4) _ExpandBytesToInt32($matB, $matBx4) $t2 = TimerInit() ; without expansion _Eigen_CwiseBinaryOp_InPlace($matAx4, "-", $matBx4) _Eigen_CwiseUnaryOp_InPlace($matAx4, "abs") $iMaxDiff = _Eigen_GetMaxVal($matAx4) ConsoleWrite("MAX DIFF: " & $iMaxDiff & " digital level" & @CRLF) ConsoleWrite("Time with byteToIntExpansion: " & Round(TimerDiff($t1)) & " ms" & @CRLF) ConsoleWrite("Time without byteToIntExpansion: " & Round(TimerDiff($t2)) & " ms" & @CRLF) _Eigen_CloseDown() Func _ExpandBytesToInt32($mat1, $mat4) _Eigen_CreateMatrix_FromA_Tiled ($mat1, 1, 4, $mat4) ; duplicate 4x horizontally _Eigen_CwiseLogicalOp_InPlace($mat4,"and",$matMask) ; remove unwanted bits ; SHR to LSByte _Eigen_CwiseScalarOp_Block_InPlace ($mat4,0,$colsInt,$rows,$colsInt,"shr",8) _Eigen_CwiseScalarOp_Block_InPlace ($mat4,0,$colsInt*2,$rows,$colsInt,"shr",16) _Eigen_CwiseScalarOp_Block_InPlace ($mat4,0,$colsInt*3,$rows,$colsInt,"shr",24) EndFunc Of course, if you can store the binary files as proper int32 in the first place (i.e., 4 times more file space needed) you wouldn't have to do all the masking and shifting here, reducing the processing (at my end) to 3 ms per file comparison. Even faster would be if you could store all binary files in a single dataset which you then block-divide and process.
    1 point
  11. Yes, I have created a DLL for one of my UDF (Screen Scraping) where looping in pure AutoIt was too slow...Ask other forum like FreeBasic or C#. By using DllStruct, it is quite easy to pass those to DLL in any other language.
    1 point
  12. Here you go. Questions, issues, bugs etc can be discussed here. EDIT: I am pretty drained and exhausted, really pounded it out thru Thursday and Friday. I want you guys to play around with it, look over the code etc. I will work on putting up more documentation and info through out the weekend. Once you have the program up and running, use /help in the command line to display commands. Thanks to all of you! I don't like to ask, but donations will help! Considering time and effort spent, I also need to invest in some more software, online stuff and computer upgrades to really help move the project along. Version 0.01 Concept Demo I used AutoIt 3.3.8.1 and SciTE Lite (I tried to use newest version of autoit and full scite but everything breaks when I switch to that...) Windows 32-Bit (x86) Compiled executable and installer (Hosted via GitHub) Source Code and Files (Hosted via GitHub) Video I threw together in the spoiler
    1 point
  13. Got about 20% faster this way, not a big deal but cleaner for sure : #AutoIt3Wrapper_UseX64=y #include <FileConstants.au3> $sPath1 = "TestPtrn_1.raw" $sPath2 = "TestPtrn_2.raw" $iSize = FileGetSize($sPath1) Local $tByte1 = DllStructCreate("byte array[" & $iSize & "]") Local $hFileOpen = FileOpen($sPath1, BitOR($FO_READ, $FO_BINARY)) $tByte1.array = FileRead($hFileOpen) FileClose($hFileOpen) Local $tByte2 = DllStructCreate("byte array[" & $iSize & "]") $hFileOpen = FileOpen($sPath2, BitOR($FO_READ, $FO_BINARY)) $tByte2.array = FileRead($hFileOpen) FileClose($hFileOpen) Local $t = TimerInit(), $iDiff, $iMaxDiff = 0 For $i = 1 To $iSize $iDiff = Abs(DllStructGetData($tByte1, 1, $i) - DllStructGetData($tByte2, 1, $i)) If $iDiff > $iMaxDiff Then $iMaxDiff = $iDiff Next ConsoleWrite("MAX DIFF: " & $iMaxDiff & " digital level" & @CRLF) ConsoleWrite("Time: " & Round(TimerDiff($t)) & " ms" & @CRLF)
    1 point
  14. You probably solved / gave up on this some time ago, but your question helped me solve it, so I'll share in case anyone else wants to turn those annoying red highlights off. Find and edit the function _UIA_DrawRect, it's enough to just include "return" at the first lane. (it's around line 2078 if I didn't do too many edits before that).
    1 point
×
×
  • Create New...