Code:
#WinActivateForce
SetWorkingDir %A_ScriptDir%
Numpad6::
WinGet, PID, PID, A
WinGet, HWND, ID, A
Address := 0x00989230
Base := getProcessBaseAddress(HWND)
WaterAddress := GetAddressWater(PID, Base, Address)
LavaAddress := GetAddressLava(PID, Base, Address)
ChocoAddress := GetAddressChoco(PID, Base, Address)
WinMove, ahk_pid %pid%,, X, Y, 1280, 720
MsgBox, 4,, Would you like to turn on auto drop boots?
Lure := 9999
Loop %Lure%
{
ifMsgBox Yes
{
Sleep, 86
ControlSend, , {c up}, ahk_pid %pid%
Sleep, 1000
ControlSend, , {f down}, ahk_pid %pid%
Sleep, 86
ControlSend, , {f up}, ahk_pid %pid%
Timer := 0
While Timer = 0
{
Loop
{
CaughtWater := ReadMemory(PID, WaterAddress)
CaughtLava := ReadMemory(PID, LavaAddress)
CaughtChoco := ReadMemory(PID, ChocoAddress)
If (CaughtWater = 1 or CaughtLava = 1 or CaughtChoco = 1)
{
Break
}
if Timer = 40
{
Break
}
Sleep, 1000
Timer := Timer + 1
}
}
Timer := 0
ControlSend, , {f down}, ahk_pid %pid%
Sleep, 86
ControlSend, , {f up}, ahk_pid %pid%
Sleep, 500
Loop, 15
{
WinActivate, ahk_pid %pid%
CoordMode, Pixel, Screen
Imagesearch, Foundx, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\img\%a_index%.png
if ErrorLevel = 0
{
CoordMode, Mouse, Screen
MouseClickDrag, Left, %FoundX%, %FoundY%, 779, 412, 5
Sleep, 200
Break
}
}
Sleep, 500
}
else
{
ControlSend, , {c down}, ahk_pid %pid%
Sleep, 86
ControlSend, , {c up}, ahk_pid %pid%
Sleep, 1000
ControlSend, , {f down}, ahk_pid %pid%
Sleep, 86
ControlSend, , {f up}, ahk_pid %pid%
Timer := 0
While Timer = 0
{
Loop
{
CaughtWater := ReadMemory(PID, WaterAddress)
CaughtLava := ReadMemory(PID, LavaAddress)
CaughtChoco := ReadMemory(PID, ChocoAddress)
If (CaughtWater = 1 or CaughtLava = 1 or CaughtChoco = 1)
{
Break
}
if Timer = 40
{
Break
}
Sleep, 1000
Timer := Timer + 1
}
}
Timer := 0
ControlSend, , {f down}, ahk_pid %pid%
Sleep, 86
ControlSend, , {f up}, ahk_pid %pid%
Sleep, 2000
}
}
ExitApp
Numpad7::
ExitApp
GetAddressWater(PID, Base, Address)
{
pointerBase := base + Address
y1 := ReadMemory(PID, pointerBase)
y2 := ReadMemory(PID, y1 + 0x144)
y3 := ReadMemory(PID, y2 + 0xe4)
Return WaterAddress := (y3 + 0x70)
}
GetAddressLava(PID, Base, Address)
{
pointerBase := base + Address
y1 := ReadMemory(PID, pointerBase)
y2 := ReadMemory(PID, y1 + 0x144)
y3 := ReadMemory(PID, y2 + 0xe4)
Return LavaAddress := (y3 + 0x514)
}
GetAddressChoco(PID, Base, Address)
{
pointerBase := base + Address
y1 := ReadMemory(PID, pointerBase)
y2 := ReadMemory(PID, y1 + 0x144)
y3 := ReadMemory(PID, y2 + 0xe4)
Return ChocoAddress := (y3 + 0x2c0)
}
getProcessBaseAddress(HWND)
{
return DllCall( A_PtrSize = 4
? "GetWindowLong"
: "GetWindowLongPtr"
, "Ptr", HWND
, "Int", -6
, "Int64") ; Use Int64 to prevent negative overflow when AHK is 32 bit and target process is 64bit
; If DLL call fails, returned value will = 0
}
ReadMemory(PID, MADDRESS)
{
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)
DllCall("ReadProcessMemory", "UInt", ProcessHandle, "Ptr", MADDRESS, "Ptr", &MVALUE, "Uint",4)
Loop 4
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)
return, result
}