okay let's do it steb-by-step
Fist of all you should know that addesses are changing evey time you start the .exe you are reading memory of
This takes as argument a window (title, or eventually other stuff, confert aahk doc) :
Code:
WinActivate [, WinTitle, WinText, ExcludeTitle, ExcludeText]
It will work with this :
or you can use something else if you want to use the process name :
Code:
WinActivate, ahk_exe Trove.exe
the Pid is correctly acquired through your function and the rest is the same as I am using so it should work
NOTE again that you have to find a new address EVERY NEW START of Trove.
Also NOTE that you have to use the DECIMAl values of the address, not the hex one :
Code:
maxHP := ReadMemory(560250528, "Trove")
currHP := ReadMemory(560250524, "Trove")
Should work better !
Also add a
At the end of your hotkeys labels, it will prevent the whole script from executing himself (and closing or doing random stuff)
That's what it lookes like fo me (tested, woking, just eplace addess with you own values) (not sue if you can change Ahk's own int epesentation to use hex by default):
Code:
^s::
WinActivate, ahk_exe Trove.exe
maxHP := ReadMemory(560250528, "Trove")
currHP := ReadMemory(560250524, "Trove")
MsgBox maxhp %maxHP% currHP %currHP%
return
esc::
ExitApp
R::
Reload
ReadMemory(MADDRESS,PROGRAM)
{
WinGet, pid, PID, %PROGRAM%
VarSetCapacity(MVALUE,4,0)
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
DllCall("ReadProcessMemory", "UInt", ProcessHandle, "Ptr", MADDRESS, "Ptr", &MVALUE, "Uint",4)
Loop 4
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)
return, result
}
- - - Updated - - -
Also I have removed the line with ';' before : it is a comment and is not usen when the script is executed