Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/05/2024 in all areas

  1. It took about 2 seconds to do a search :
    2 points
  2. Yeah! it works for me, Thank you !
    2 points
  3. As discussed here: I created a DLL (x86 and x64) to do a file compare like the FC.exe does (only binary comparison!) but filling up the memory which can be read out by Autoit. UDF _WinAPI_FileCompare.au3: ;Version v0.70 build 2024-03-23 beta #include-once ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_FileCompareBinaryString ; Description ...: Reads two files into the memory and compares them byte by byte. Result is saved in the memory. ; Syntax ........: _WinAPI_FileCompareBinaryString($sFile1, $sFile2, Byref $tMemArray) ; Parameters ....: $sFile1 - first file to read. ; $sFile2 - second file to read. ; $tMemArray - a ptr dll struct which holds a ptr entry which is filled by the DLL. ; Return values .: Number of unequal bytes found in both files otherwise negative value on error. ; Author ........: UEZ ; Modified ......: ; Remarks .......: The memory pointer $tMemArray must be released using _MemGlobalFree() which holds the pointer to the result. ; The result contains hex string values (offset, file1, file2) from the differences between the two files. ; Large memory consumption for files > 80 MB as everything is kept in memory! ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/index.php?showtopic=211619 ; Example .......: No ; =============================================================================================================================== Func _WinAPI_FileCompareBinaryString($sFile1, $sFile2, ByRef $tMemArray) If Not FileExists($sFile1) Then Return SetError(-10, 0, 0) If Not FileExists($sFile2) Then Return SetError(-20, 0, 0) If Not FileGetSize($sFile1) Then Return SetError(-30, 0, 0) If Not FileGetSize($sFile2) Then Return SetError(-40, 0, 0) If Not IsDllStruct($tMemArray) Then Return SetError(-50, 0, 0) Local $aReturn = DllCall(@AutoItX64 ? "_WinAPI_FileCompare_x64.dll" : "_WinAPI_FileCompare.dll", "int64", "_WinAPI_FileCompareBinaryString", "str", $sFile1, "str", $sFile2, "struct*", $tMemArray) If @error Then Return SetError(-60, 0, 0) If $aReturn[0] < 0 Then SetError($aReturn[0], 0, 0) Return $aReturn[0] EndFunc ;==>_WinAPI_FileCompareBinaryString ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_FileCompareBinary ; Description ...: Reads two files into the memory and compares them byte by byte. Result is saved in the memory. ; Syntax ........: _WinAPI_FileCompareBinary($sFile1, $sFile2, Byref $tMemArray) ; Parameters ....: $sFile1 - first file to read. ; $sFile2 - second file to read. ; $tMemArray - a ptr dll struct which holds a ptr entry which is filled by the DLL. ; Return values .: Number of unequal bytes found in both files otherwise negative value on error. ; Author ........: UEZ ; Modified ......: ; Remarks .......: The memory pointer $tMemArray must be released using _MemGlobalFree() which holds the pointer to the result. ; The result contains integer values (offset, file1, file2) from the differences between the two files. ; Large memory consumption as everything is kept in memory but 1/3 less than _WinAPI_FileCompareBinaryString. ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/index.php?showtopic=211619 ; Example .......: No ; =============================================================================================================================== Func _WinAPI_FileCompareBinary($sFile1, $sFile2, ByRef $tMemArray) If Not FileExists($sFile1) Then Return SetError(-10, 0, 0) If Not FileExists($sFile2) Then Return SetError(-20, 0, 0) If Not FileGetSize($sFile1) Then Return SetError(-30, 0, 0) If Not FileGetSize($sFile2) Then Return SetError(-40, 0, 0) If Not IsDllStruct($tMemArray) Then Return SetError(-50, 0, 0) Local $aReturn = DllCall(@AutoItX64 ? "_WinAPI_FileCompare_x64.dll" : "_WinAPI_FileCompare.dll", "int64", "_WinAPI_FileCompareBinary", "str", $sFile1, "str", $sFile2, "struct*", $tMemArray) If @error Then Return SetError(-60, 0, 0) If $aReturn[0] < 0 Then SetError($aReturn[0], 0, 0) Return $aReturn[0] EndFunc ;==>_WinAPI_FileCompareBinary ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_FileComparePrint ; Description ...: Reads two files into the memory and compares them byte by byte. Result will be printed to the console only. ; Syntax ........: _WinAPI_FileComparePrint($sFile1, $sFile2[, $bUnbuffered = False]) ; Parameters ....: $sFile1 - first file to read. ; $sFile2 - second file to read. ; $bUnbuffered - [optional] a boolean value. Default is False. If $bUnbuffered then file will be read ; byte by byte and result will be displayed, otherwise both files will be read into the ; memory and then compared. ; Return values .: 1 if successfull, otherwise 0. ; Author ........: UEZ ; Modified ......: ; Remarks .......: Use #AutoIt3Wrapper_Change2CUI=y when compiling to display result in console. ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/index.php?showtopic=211619 ; Example .......: No ; =============================================================================================================================== Func _WinAPI_FileComparePrint($sFile1, $sFile2, $bUnbuffered = False) If Not FileExists($sFile1) Then Return SetError(-10, 0, 0) If Not FileExists($sFile2) Then Return SetError(-20, 0, 0) If Not FileGetSize($sFile1) Then Return SetError(-30, 0, 0) If Not FileGetSize($sFile2) Then Return SetError(-40, 0, 0) DllCall(@AutoItX64 ? "_WinAPI_FileCompare_x64.dll" : "_WinAPI_FileCompare.dll", "none", "_WinAPI_FileComparePrint", "str", $sFile1, "str", $sFile2, "bool", $bUnbuffered) If @error Then Return SetError(-60, 0, 0) Return 1 EndFunc ;==>_WinAPI_FileComparePrint Func _WinAPI_FileCompareAbout() DllCall(@AutoItX64 ? "_WinAPI_FileCompare_x64.dll" : "_WinAPI_FileCompare.dll", "none", "About") EndFunc ;==>_WinAPI_FileCompareAbout Example1: ;Coded by UEZ build 2024-03-22 beta #AutoIt3Wrapper_UseX64=y #include <WinAPIFiles.au3> #include <Memory.au3> #include "_WinAPI_FileCompare.au3" Global $tMemArray = DllStructCreate("ptr addr") Global $fTimer = TimerInit() Global $iReturn = _WinAPI_FileCompareBinaryString("img1.bmp", "img2.bmp", $tMemArray) ConsoleWrite("Dll runtime: " & TimerDiff($fTimer) & " ms" & @CRLF) If $iReturn Then If _WinAPI_IsBadReadPtr($tMemArray.addr, $iReturn) <> 1 Then ConsoleWrite(@CRLF) ConsoleWrite("Displaying result..." & @CRLF) ConsoleWrite("Offset" & @TAB & @TAB & "File1" & @TAB & "File2" & @CRLF) Global $i, $j, $t, $c = 0 For $i = 0 To $iReturn For $j = 0 To 2 $t = DllStructCreate("char string[15]", Ptr($tMemArray.addr + $i * 15 + ($j = 0 ? $j : 6 + $j * 3))) ConsoleWrite($t.string & ($j = 0 ? ":" : "") & @TAB) Next $c += 1 ConsoleWrite(@CRLF) Next ConsoleWrite(@CRLF) ConsoleWrite("Found " & $c & " differences!" & @CRLF) ConsoleWrite(@CRLF) If $tMemArray.addr Then _MemGlobalFree($tMemArray.addr) Else ConsoleWrite("Access violation to memory address" & @CRLF) EndIf Else ConsoleWrite("Files are equal!" & @CRLF) EndIf Example2: ;Coded by UEZ build 2024-03-22 beta #AutoIt3Wrapper_UseX64=y #include <WinAPIFiles.au3> #include <Memory.au3> #include "_WinAPI_FileCompare.au3" Global $tMemArray = DllStructCreate("ptr addr") Global $fTimer = TimerInit() Global $iReturn = _WinAPI_FileCompareBinary("img1.bmp", "img2.bmp", $tMemArray) ConsoleWrite("Dll runtime: " & TimerDiff($fTimer) & " ms" & @CRLF) If $iReturn Then If _WinAPI_IsBadReadPtr($tMemArray.addr, $iReturn) <> 1 Then ConsoleWrite(@CRLF) ConsoleWrite("Displaying result..." & @CRLF) ConsoleWrite("Offset" & @TAB & @TAB & "File1" & @TAB & "File2" & @CRLF) Global $i, $j, $t, $c = 0 For $i = 0 To $iReturn For $j = 0 To 2 Switch $j Case 0 $t = DllStructCreate("ulong offset", Ptr($tMemArray.addr + $i * 8)) ConsoleWrite(Hex($t.offset, 8) & ":" & @TAB) Case 1 $t = DllStructCreate("ubyte hex1", Ptr($tMemArray.addr + $i * 8 + 4)) ConsoleWrite(Hex($t.hex1, 2) & @TAB) Case 2 $t = DllStructCreate("ubyte hex2", Ptr($tMemArray.addr + $i * 8 + 5)) ConsoleWrite(Hex($t.hex2, 2) & @TAB) EndSwitch Next $c += 1 ConsoleWrite(@CRLF) Next ConsoleWrite(@CRLF) ConsoleWrite("Found " & $c & " differences!" & @CRLF) ConsoleWrite(@CRLF) If $tMemArray.addr Then _MemGlobalFree($tMemArray.addr) Else ConsoleWrite("Access violation to memory address" & @CRLF) EndIf Else ConsoleWrite("Files are equal!" & @CRLF) EndIf Example3: ;Coded by UEZ build 2024-03-22 beta #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Change2CUI=y #include "_WinAPI_FileCompare.au3" _WinAPI_FileComparePrint("img1.bmp", "img2.bmp") I used the two images from here: Examples output should look like this here (always hex values): Dll runtime: 5.6315 ms Displaying result... Offset File1 File2 0009AB99: F0 C7 0009AB9A: EF CB 0009AB9B: 81 34 0009C795: 23 00 0009C796: 7C 80 0009C797: F5 FF Found 6 differences! You can read out the result and put it to an array... With this version you should be able to use multi-threading / multi-calls of the DLL as the memory is now allocated with each call. For x86 it may fail when the memory cannot be allocated (2GB limit) and the dll will return 0. I may add another feature to the DLL to get around the x86 limitation at the expense of speed by using chunked memory allocation if it makes sense... All files can be found also in the 7-Zip archive. _WinAPI_FileCompare DLL v0.70 build 2024-03-22.7z
    1 point
  4. That's work perfectly!! Thank you!!!
    1 point
  5. I think _GUICtrlEdit_SetSel($g_idMemo, $start, $linelength+1) needs to be _GUICtrlEdit_SetSel($g_idMemo, $start, $start + $linelength+1)
    1 point
  6. argumentum

    RdpShadow utility

    Nothing you could not get from the forum as far as functionality. The rest is GUI stuff. Didn't post the code because is a mess as I said here. As soon as I can have the HiDpi and DarkMode done I'll share the code with their corresponding UDFs.
    1 point
  7. @Acanis: As they say in German: "Da gibt's noch Luft nach oben." You're making things faaaaaar too complicated (I'm not even going to go into how you're setting up/evaluating your 3D/2D grid...). Was this ChatGPT's idea? But you earn some points for at least annotating your code. Or was that ChatGPT as well? I edited the TSP example on the assumption that the desired number of intermediate points is fixed, and point duplication is not allowed. You can play with $tempfactor (and $maxStepsWithoutImprovement) to adjust how much exploration of the solution space is allowed. If $verbose = true (default false now), the best sequence of journey legs so far is ArrayDisplayed every time a better solution is found (press <Esc> (every time) to continue); press <Space> to terminate prematurely. This is all I'm going to write for you here; visualisation and any changes you'll have to implement yourself. Hope it helps.
    1 point
  8. https://github.com/microsoft/cascadia-code
    1 point
  9. Looks even better.
    1 point
  10. <Link removed> (The transfer you requested has been deleted.) Meh. My font. Hurry. You only have 11 month to get it. Act Now. Saw it on TV and now I have the "act now" stuck in my brain 🤪 Addendum: "Simply upload a file, share the link, and after it is downloaded, the file is completely deleted." The more you know read
    1 point
  11. Changed to Source Code Pro and looks good. Thanks.
    1 point
  12. Maybe the selected font for monospaced ain't monospaced. This is what am using: The font I stole took from another PC of mine. No idea why is not part of the default fonts in every version.
    1 point
  13. ioa747

    ResourcesEx UDF.

    Note with last ResourcesEx 27-4-2023 updated to get Example.au3 to work with AutoIt Version..: 3.3.16.1, I needed to make the following change in Func IsXP() Func IsXP() ;~ Return $__WINVER < 0x0600 Return _WinAPI_GetVersion() < 6 EndFunc ;==>IsXP
    1 point
  14. For those of us who use SciTE4AutoIt3 then you would've come across (at some stage) the directive #AutoIt3Wrapper_Res_SaveSource, it allows you to save the script to the compiled exe thus allowing you to retrieve at a later stage, great if you accidentally delete your source file. _GetSavedSource() allows you to extract the source file from the compiled executable and save to a file of your choice. Note: You must use #AutoIt3Wrapper_Res_SaveSource=Y at the top of the script for this to work & it must be compiled. Function: #include-once #include <WinAPIRes.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GetSavedSource ; Description ...: Retrieve the source file from a compiled executable, #AutoIt3Wrapper_Res_SaveSource=Y must be used beforehand to embed the file to the executable ; Syntax ........: _GetSavedSource([$sExecutable = ''[, $sSaveFilePath = '']]) ; Parameters ....: $sExecutable - [optional] Executable to retrieve the source file from ; Use a blank string or the Default keyword to use the current executable. Default is '' ; $sSaveFilePath - [optional] FilePath to save the source file to. Nore: The file doesn't have to exist. Default is '' ; Use a blank string or the Default keyword to save to the current directory and using the script's ; name with the au3 prefix. Default is '' ; Return values .: Success - True ; Failure - False and sets @error to non-zero ; Author ........: guinness ; Remarks .......: ; Example .......: Yes ; Note ..........: Thanks to Jos, Yashied & Zedna ; =============================================================================================================================== Func _GetSavedSource($sExecutable = '', $sSaveFilePath = '') Local Enum $GETSAVEDSOURCE_ERROR_NONE, $GETSAVEDSOURCE_ERROR_FILEWRITE, $GETSAVEDSOURCE_ERROR_FINDRESOURCE, $GETSAVEDSOURCE_ERROR_LOADMODULE Local $iError = $GETSAVEDSOURCE_ERROR_LOADMODULE Local $hInstance = (($sExecutable = Default Or StringStripWS($sExecutable, $STR_STRIPALL) = '') ? _WinAPI_GetModuleHandle(Null) : _WinAPI_LoadLibraryEx($sExecutable, $LOAD_LIBRARY_AS_DATAFILE)) If Not @error Then $iError = $GETSAVEDSOURCE_ERROR_FINDRESOURCE ; Get the source file from the executable. This is located at resname 999 Local $hResource = _WinAPI_FindResource($hInstance, $RT_RCDATA, 999) If Not @error Then Local $hData = _WinAPI_LoadResource($hInstance, $hResource) Local $iSize = _WinAPI_SizeOfResource($hInstance, $hResource) Local $pResource = _WinAPI_LockResource($hData) If $sSaveFilePath = Default Or StringStripWS($sSaveFilePath, $STR_STRIPALL) = '' Then $sSaveFilePath = @ScriptDir & '\' & StringLeft(@ScriptName, StringInStr(@ScriptName, '.', $STR_NOCASESENSEBASIC, -1) - 1) EndIf $iError = $GETSAVEDSOURCE_ERROR_FILEWRITE Local $hFilePath = FileOpen($sSaveFilePath, BitOR($FO_OVERWRITE, $FO_BINARY, $FO_UTF8)) If $hFilePath > -1 Then $iError = $GETSAVEDSOURCE_ERROR_NONE Local $tBuffer = DllStructCreate('byte array[' & $iSize & ']', $pResource) FileWrite($hFilePath, DllStructGetData($tBuffer, 'array')) FileClose($hFilePath) EndIf EndIf _WinAPI_FreeLibrary($hInstance) EndIf Return SetError($iError, 0, $iError = $GETSAVEDSOURCE_ERROR_NONE) EndFunc ;==>_GetSavedSource Example 1 of Function: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; Use the full version of SciTE4AutoIt3 by Jos #AutoIt3Wrapper_Res_SaveSource=Y #AutoIt3Wrapper_UseX64=N #include <MsgBoxConstants.au3> #include '_GetSavedSource.au3' Example() Func Example() If @Compiled Then If _GetSavedSource(@ScriptFullPath, @ScriptDir & '\' & GetScriptName() & '.au3') Then MsgBox($MB_SYSTEMMODAL, 'Completed', 'The Au3 script was saved in the script directory and is called ' & GetScriptName() & '.au3') Else MsgBox($MB_SYSTEMMODAL, 'Error' & @error, 'An error occurred whilst extracting the Au3 script located in the resources.') EndIf Else MsgBox($MB_SYSTEMMODAL, 'Compile first', 'Please compile this script first and then run the compiled file, you''ll see a new file called "' & _ GetScriptName() & '.au3' & '" is created in the same directory.') EndIf EndFunc ;==>Example ; Return the @ScriptName minus the .exe or .au3 extension and with _SAVEDSOURCE_ appended Func GetScriptName() Return StringLeft(@ScriptName, StringInStr(@ScriptName, '.', $STR_NOCASESENSEBASIC, -1) - 1) & '_SAVEDSOURCE_' EndFunc ;==>GetScriptName Example 2 of Function: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; Use the full version of SciTE4AutoIt3 by Jos #AutoIt3Wrapper_Res_SaveSource=Y #AutoIt3Wrapper_UseX64=N #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include '_GetSavedSource.au3' If Not @Compiled Then Exit MsgBox($MB_SYSTEMMODAL, 'Compile first', 'Please compile this script first and then run the compiled file, you''ll see a new file called "' & _ GetScriptName() & '.au3' & '" is created in the same directory.') EndIf ; Check if the commandline parameter 'SaveSource' has been passed to the executable IsSaveSource() Example() Func Example() ; The example of using AutoItWinGetTitle() can be found at: http://www.autoitscript.com/forum/topic/133648-autoitwingettitleautoitwinsettitle-an-example-of-usage/ ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window Local $hAutoIt = AutoItWinShow() ; Read the source file that was extracted from the executable Local $sData = FileRead(@ScriptDir & '\' & GetScriptName() & '.au3') If @error Then ; If the file wasn't extracted then show an error string $sData = '## @error - can''t open the file ##' EndIf ; Set the text of the edit box using the data returned from _GetFile AutoItWinSetText($hAutoIt, $sData) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Just hit the close button to Exit the application ExitLoop EndSwitch WEnd EndFunc ;==>Example ; Add text to AutoIt's Hidden Window Func AutoItWinSetText($sString, $hWnd = Default) If Not IsHWnd($hWnd) Or $hWnd = Default Then ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window $hWnd = WinGetHandle(AutoItWinGetTitle()) EndIf Return ControlSetText($hWnd, '', ControlGetHandle($hWnd, '', 'Edit1'), $sString) EndFunc ;==>AutoItWinSetText ; Display AutoIt's Hidden Window. Returns the handle of the window Func AutoItWinShow() ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window Local $hWnd = WinGetHandle(AutoItWinGetTitle()) ; Move the AutoIt Hidden Window and re-size for a better view of the data that will be set WinMove($hWnd, '', (@DesktopWidth / 2) - 250, (@DesktopHeight / 2) - 250, 500, 500) ; Show the AutoIt Hidden Window, normally this is hidden, but in the interest of this example I'm displaying it WinSetState($hWnd, '', @SW_SHOW) Return $hWnd EndFunc ;==>AutoItWinShow ; Return the @ScriptName minus the .exe or .au3 extension and with _SAVEDSOURCE_ appended Func GetScriptName() Return StringLeft(@ScriptName, StringInStr(@ScriptName, '.', $STR_NOCASESENSEBASIC, -1) - 1) & '_SAVEDSOURCE_' EndFunc ;==>GetScriptName ; Check if the commandline parameter 'SaveSource' has been passed to the executable Func IsSaveSource() Return (StringInStr($CmdLineRaw, 'SaveSource') ? _GetSavedSource(@ScriptFullPath, @ScriptDir & '\' & GetScriptName() & '.au3') : Null) EndFunc ;==>IsSaveSource All of the above has been included in a ZIP file. GetSavedSource.zip
    1 point
  15. Hi there, while I created an example script to generate and execute a function during runtime, I stumbled across a neat way to share data between running autoit scripts. This is done using the amazing magic of AutoItObject_Internal . (You'll need at least Version 3.0.0 of AutoItObject_Internal) Using this UDF, you can create a shared data storage, basically an empty "AutoitObject_Internal-"Object which you can then use to write / read data Inline. no set/get methods, just #include "AutoItSharedData.au3" $oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID") $oShare.some_data = 'foo' and you're done. any other script accessing this data will have to do: #include "AutoItSharedData.au3" $oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID") ConsoleWrite($oShare.some_data & @LF) Basically it's Larsj's Implementing IRunningObjectTable Interface, but you dont have a Dictionary, but an IDIspatch Object instead. There are already a bunch of IPC options available - and this is another one. AutoItSharedData.au3 Example Script 1 Example Script 2 Output: To test: run Example Script 1, Then run example Script 2.. or the other way around. Example Script 3 Example_sharedata3.au3 Example_sharedata3_Controlsend.au3 Example_sharedata3_Tooltip.au3 To test: run Example_sharedata3.au3. Output: Example SharedData4: Output: /Edit: Please note that there's a limitation with the Running object table : The Script accessing a variable first, will be the "server" for this variable. This means, access to that variable from other scripts should only be possible, as long the "server" script is running! Use appropriate Object Error handlers in case you don't want the surviving "clients" to crash. Feedback and/or improvements appreciated changelog version 2.0 Removed need for AutoItObject, as AutoItObject_Internal now comes with ROT support Added UDF Header Fixed typo on "#include AutoItObjectInternal.au3" -> "#include AutoItObject_Internal.au3" Added ObjGet() after registering the object fails (in case 2 programs tried to register the same ID simultaneously) Updated Examples & zip archive. Cheers, AutoItSharedData.zip
    1 point
  16. Hello, I know it's an old topic, but I had problem during redirect AutoIt command line output to log file with Windows Batch script. Example: ConsoleWrite ("Line 1" & @LF) ConsoleWrite ("Line 2" & @LF) Perform compiled exe output in batch command line redirected to log file as a result in Batch log file ConsoleWrite output is: Line 1Line 2 Using "@CRLF": ConsoleWrite ("Line 1" & @CRLF) ConsoleWrite ("Line 2" & @CRLF) and perform compiled exe output in batch command line redirected to log file as a result in Batch log file ConsoleWrite output was now correct: Line 1 Line 2 Thanks to @hannes08 for explanation
    1 point
×
×
  • Create New...