Code:
#NoEnv
SendMode Input
CoordMode, ToolTip, Screen
SetTitleMatchMode, 3
SetKeyDelay, 0, 2
LureCount := 0
Failsafe := 0
Numpad9::
WinGet, pidn, PID, A
pid := pidn
WinGet, hwnds, ID, A
Handle := hwnds
InputBox, Lure, Lure's, How many Lure's do you have in inventory?
Loop %Lure%
{
LureCount := LureCount +1
ControlSend, , {f down}, ahk_pid %pid%
Sleep, 86
ControlSend, , {f up}, ahk_pid %pid%
Catch := 0
Loop
{
If (Catch = 1)
{
break
}
else
{
if (Failsafe = 40)
{
ControlSend, , {f down}, ahk_pid %pid%
Sleep, 86
ControlSend, , {f up}, ahk_pid %pid%
Failsafe := 0
}
Base := getProcessBaseAddress()
CaughtWater := ReadMemory((ReadMemory(base + 0x008E6660) + 0xBD150))
CaughtLava := ReadMemory(((ReadMemory(base + 0x008E6660) + 0xBD150) + 0x4A4))
If (CaughtWater = 1 or CaughtLava = 1)
{
ControlSend, , {f down}, ahk_pid %pid%
Sleep, 86
ControlSend, , {f up}, ahk_pid %pid%
Random, Wait, 2000, 3500
Sleep, %Wait%
Failsafe := 0
Catch := 1
}
else
{
Sleep, 1000
Failsafe := (Failsafe +1)
}
}
}
}
ExitApp
Numpad7::
ExitApp
getProcessBaseAddress()
{
Global Handle
return DllCall( A_PtrSize = 4
? "GetWindowLong"
: "GetWindowLongPtr"
, "Ptr", Handle
, "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(MADDRESS)
{
Global pid
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
}