Hey guys need some help, AHK script

02/01/2013 11:06 Darkyy#1
Sup people,
I havn't been here in ages or used AHK so i forgot some main actions with it. I'm trying to do an automatic gear shifter for a racing game I'm playing but with no success. I got the memory code of the gear and the speed and I want it to change gear up or down if it's in "X" gear at "Y" speed. So far i made something like this:

Code:
loop 
{
speed:=ReadMemoryNumber(0x00599CD8,"Synetic")   
Gear:=ReadMemoryNumber(0x00599C8A,"Synetic")   
tooltip, %speed%  %Gear% , 130, 95 ,1 
sleep 1000
}




If speed >= 25
{


if Gear = 1 
{
if ErrorLevel = 0
 {
loop
sleep 50
send A
sleep 50
send {A}
sleep 50
}


}


}









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,"UInt",MADDRESS,"Str",MVALUE,"UInt",4,"UInt *",0)

Loop 4
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)

return, result 
} 

ReadMemoryText(MADDRESS,PROGRAM)
{
winget, pid, PID, %PROGRAM%
VarSetCapacity(MVALUE,22,22)
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
DllCall("ReadProcessMemory","UInt",ProcessHandle,"UInt",MADDRESS,"Str",MVALUE,"UInt",22,"UInt *",22)
Loop 4
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)
SetFormat, Integer, Hex
result+=0
count=1

loop 4
{
count+=2
StringMid, c, result, %count%, 2
c=0x%c%
c:=chr(c)
final=%c%%final%
}
return, final 
}

ReadMemoryNumber(MADDRESS,PROGRAM)
{
winget, pid, PID, %PROGRAM%
SetFormat, Integer, d

VarSetCapacity(MVALUE,4,0)
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
DllCall("ReadProcessMemory","UInt",ProcessHandle,"UInt",MADDRESS,"Str",MVALUE,"UInt",4,"UInt *",0)

Loop 4
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)

return, result 
}

On the tooltip it shows the correct speed and gear but In-game it doesn't do anything at the shown speed or gear. If someone has time and wants to help i'll be thankful. :mofo: