https://autohotkey.com/boards/viewtopic.php?f=5&t=31288
I'm also trying to figure out how to correctly read the pointer to a memory address so I don't have to change my script every time I load up my headset software.
I initially used CheatEngine to figure out what memory address was used to store my headset's battery level, and then reading through some other threads about how to figure out the pointer address, I came up with: I tried using the offset (0x67E770B) in the following code:
Code: Select all
#SingleInstance force
#Include <classMemory>
if (_ClassMemory.__Class != "_ClassMemory")
msgbox class memory not correctly installed. Or the (global class) variable "_ClassMemory" has been overwritten
Process, Exist, ASTRO Command Center.exe
pid := ErrorLevel
if !pid
{
msgbox pid not found
ExitApp
}
mem := new _ClassMemory("ahk_pid " pid, "", hProcessCopy)
; Check if the above method was successful.
if !isObject(mem)
{
msgbox failed to open a handle
if (hProcessCopy = 0)
msgbox The program isn't running (not found) or you passed an incorrect program identifier parameter.
else if (hProcessCopy = "")
msgbox OpenProcess failed. If the target process has admin rights, then the script also needs to be ran as admin. Consult A_LastError for more information.
ExitApp
}
; setformat is only used to make displayed number easier to read
SetFormat, IntegerFast, H
; *** if .exe is 64 bit then the AHK script must be 64 bit***
msgbox % "Base Address: " mem.BaseAddress
SetFormat, IntegerFast, d
pointerHSBat := [0x67E770B + mem.BaseAddress, "UInt", 0x10, 0x20, 0x20, 0x124]
msgbox % "HSBatLeft: " mem.read(pointerHSBat*)