Jump to content

I am creating tool to patch / modify hex file. How to run several patch together at the same time?


Recommended Posts

Posted

I just create tool to patch / modify hex file
 

While 1
   While $Standby = True
       ; Open the file for binary read and load content
       $hFile = FileOpen('D:\Projects\exampleori', 16)
       $bRead = FileRead($hFile)
       FileClose($hFile)

        ;Display a progress bar window.
        ProgressOn("Progress Meter", "Begin Convert / Revert Process", "0%", 1180, 1400, 16)

       ; Do your processing stuff
       ProgressSet(((33-33)*100/26889) & "%", "Starting Convert / Revert Process")
       $bRead = StringRegExpReplace($bRead, $suba64w0w0w0, $mova64w0c0)
       $bRead = StringRegExpReplace($bRead, $suba64w0w1w1, $mova64w0c0)
       $bRead = StringRegExpReplace($bRead, $suba64w0w2w2, $mova64w0c0)
       ...
       ...
       ...
       $bRead = StringRegExpReplace($bRead, $mova64x29x29, $nopa64)
       $bRead = StringRegExpReplace($bRead, $mova64x30x30, $nopa64)
       $bRead = StringRegExpReplace($bRead, $mova64x31x31, $nopa64)
       ProgressSet(100 & "%", "Done", "Complete")
       Sleep(500)

        ; Close the progress window.
        ProgressOff()
        
       ;Open the file for binary write and save content
       $hFile = FileOpen('D:\Projects\exampleoriconvert', 18)
       FileWrite($hFile, $bRead)
       FileClose($hFile)
       ;
       $Standby = False
   WEnd
WEnd

when I run it, It needs about 3 hours to be completed
If I want to patch 4 files at the same time, I create 4 copy of my autoit file, then run it one by one

How to execute my tools to patch 4 files at the same time using only 1 autoit file?

I want the result to be like the picture below

Patch.png

Posted (edited)

For simple such tasks I use _CmdLineWatcher()
 

;~ #NoTrayIcon
#include <Array.au3>

;   Important Note:
;   The parameter received from $CmdLine is of type text.
;   If the function requires a different variable type,
;   it is essential to perform a type check within the function and,
;   if needed, convert the parameter to the appropriate type.


_CmdLineWatcher()

Local $Executable = @Compiled ? '"' & @ScriptFullPath & '"' : '"' & @AutoItExe & '" "' & @ScriptFullPath & '"'

Run($Executable & ' _Msg "1st Msg" "This is first msg" 3')
Run($Executable & ' _Msg "2nd Msg" "This is second msg" 3')
Run($Executable & ' _Msg "3rd Msg" "This is third msg" 3')
Run($Executable & ' _Msg "4th Msg" "This is fourth msg" 3')
Sleep(100)

Run($Executable & ' _ride "1st Msg" 20 20 1')
Run($Executable & ' _ride "2nd Msg" ' & @DesktopWidth * 0.8 & ' 20 1')
Run($Executable & ' _ride "3rd Msg" ' & @DesktopWidth * 0.8 & ' ' & @DesktopHeight * 0.8 & ' 1')
Run($Executable & ' _ride "4th Msg" 20 ' & @DesktopHeight * 0.8 & ' 1')
Sleep(1000)

Run($Executable & ' _ride "1st Msg" ' & @DesktopWidth * 0.8 & ' 20')
Run($Executable & ' _ride "2nd Msg" ' & @DesktopWidth * 0.8 & ' ' & @DesktopHeight * 0.8)
Run($Executable & ' _ride "3rd Msg" 20 ' & @DesktopHeight * 0.8)
Run($Executable & ' _ride "4th Msg" 20 20')


;---------------------------------------------------------------------------------------
Func _Msg($title, $msg, $timeout = 0)
    MsgBox(0, $title, $msg, $timeout)
EndFunc   ;==>_Msg
;---------------------------------------------------------------------------------------
Func _ride($title, $destX, $destY, $step = 100)
    Local $hWnd = WinGetHandle($title)
    If $hWnd Then
        Local $aPos = WinGetPos($hWnd)
        Local $stepX = ($destX - $aPos[0]) / $step
        Local $stepY = ($destY - $aPos[1]) / $step
        Local $x = $aPos[0], $y = $aPos[1]
        For $i = 1 To $step
            $x += $stepX
            $y += $stepY
            WinMove($hWnd, "", $x, $y)
        Next
    EndIf
EndFunc   ;==>_ride
;---------------------------------------------------------------------------------------
Func _CmdLineWatcher()
    ; Run('"' & @AutoItExe & '" "' & @ScriptFullPath & '" FoldersGUI ' & $hWnd & ' 1')
    Local $aArgs = $CmdLine
    Local $sFunc
    If $aArgs[0] > 0 Then
        $sFunc = $aArgs[1]
        _ArrayDelete($aArgs, 1)
        $aArgs[0] = "CallArgArray"
        Call($sFunc, $aArgs)
        If @error = 0xDEAD And @extended = 0xBEEF Then
            ToolTip("error !! Function does not exist" & @CRLF & "or wrong number of parameter", Default, Default, @ScriptName, 3)
            Sleep(4000)
            ToolTip("")
        EndIf
        Exit
    EndIf

EndFunc   ;==>_CmdLineWatcher
;----------------------------------------------------------------------------------------

 

a real example of use you can see here:  212478-active_filedlg/
:)

Edited by ioa747
added ;~ #NoTrayIcon

I know that I know nothing

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
  • Recently Browsing   0 members

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