Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

AutoHotkey in C#

$
0
0

Help to convert code from AutoHotkey in C#

#NoEnv
        if not A_IsAdmin {
           Run *RunAs "%A_ScriptFullPath%"
           ExitApp
        }
        IniRead, Address, NoTrialHud.ini, Address, Address, 0
        if !Address
        {
           Address = 0x021AF244
           IniWrite, %Address%, NoTrialHud.ini, Address, Address
        }

        ProcessName = PokerTracker4.exe
        Process, exist, %ProcessName%
        if ErrorLevel
        {
            MsgBox `tPoker Tracker 4 работает!`nЗакройте его и запустите программу заново!
           ExitApp
        }

        if A_OSVersion in WIN_7,WIN_8,WIN_VISTA
        Run *RunAs %ProcessName%,, UseErrorLevel
        else
        Run %ProcessName%,, UseErrorLevel
        if ErrorLevel = ERROR
        {
            MsgBox Не найден Poker Tracker 4!
           ExitApp
        }
        WinWait, PokerTracker Trial Version,,20
        If ErrorLevel
        {
           MsgBox Ошибка запуска программы!
           ExitApp
        }
        Control, Enable,, Button3, PokerTracker Trial Version
        ControlClick, Button3, PokerTracker Trial Version,,,2

        Gosub ReadStr
        if Result ; Result != 0, значит по этому адресу нет строки
        {
           MsgBox Строка не найдена по указанному адресу!
           ExitApp
        }
        Gosub ZeroString

        ; =========================================================
        ReadStr:
        ReadSize = 2                      ; 
        VarSetCapacity(Buf, ReadSize, 0)  ; 

        PROCESS_VM_READ = 0x10            ; 

        Process, Exist, %ProcessName%     ; 

        If(!ErrorLevel) {
          MsgBox, Процесс не найден.
          ExitApp
        }

        PID := ErrorLevel                 ; 

        hProcess := DllCall("OpenProcess", UInt, PROCESS_VM_READ
                                         , Int, False
                                         , UInt, PID)
        If(!hProcess) {
          MsgBox, Не удалось открыть процесс.
          ExitApp
        }

        Ret := DllCall("ReadProcessMemory", UInt, hProcess
                                          , UInt, Address
                                          , UInt, &Buf
                                          , UInt, ReadSize
                                          , UInt, 0)

        DllCall("CloseHandle", UInt, hProcess) ; 

        If(!Ret) {
          MsgBox, Не удалось прочитать.
          ExitApp
        }

        Result := NumGet(Buf, 0, "UInt") - 0x5254  ; 
        ; 0x5254 - Начало строки TRIAL...
        return

        ; =========================================================
        ZeroString:
        Size = 22                          ; 
        VarSetCapacity(Buf, Size, 0)      ; 

        NumPut(Data, Buf, 0, "UInt")      ; 

        PROCESS_VM_WRITE = 0x20           ; 
        PROCESS_VM_OPERATION = 0x8

        Process, Exist, %ProcessName%     ; 

        If(!ErrorLevel) {
          MsgBox, Процесс не найден.
          ExitApp
        }

        PID := ErrorLevel                 ; 

        hProcess := DllCall("OpenProcess", "UInt", PROCESS_VM_WRITE | PROCESS_VM_OPERATION
                                         , "Int",  False
                                         , "UInt", PID)
        If(!hProcess) {
          MsgBox, Не удалось открыть процесс.
          ExitApp
        }

        Ret := DllCall("WriteProcessMemory", "UInt", hProcess
                                           , "UInt", Address
                                           , "UInt", &Buf
                                           , "UInt", Size
                                           , "UInt", 0)

        DllCall("CloseHandle", "UInt", hProcess) ; 

        If(!Ret) {
          MsgBox, Не удалось записать.
          ExitApp
        }
        return


Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>