Code:
#NoEnv
SendMode Input
CoordMode, ToolTip, Screen
SetTitleMatchMode, 3
SetKeyDelay, 0, 2
Numpad9::
WinGet, pidn, PID, A
pid := pidn
WinGet, hwnds, ID, A
Handle := hwnds
Break := 0
InputBox, Lure, Lure's, How many Lure's do you have in inventory?
LureCount := 0
Loop %Lure%
{
LureCount := LureCount +1
ControlSend, , {f down}, ahk_pid %pid%
Sleep, 86
ControlSend, , {f up}, ahk_pid %pid%
Catch := 0
Loop
{
If (Break = 1 or Catch = 1)
{
break
}
else
{
Base := getProcessBaseAddress()
pointerBase := base + 0x008E5360
y1 := ReadMemory(pointerBase)
y2 := ReadMemory(y1 + 0x20)
y3 := ReadMemory(y2 + 0x4)
y4 := y3 + 0x320
CameraY := ReadMemory(y4)
If (CameraY = 1)
{
ToolTips = 1
SetTimer, ToolTip, 500
ControlSend, , {f down}, ahk_pid %pid%
Sleep, 86
ControlSend, , {f up}, ahk_pid %pid%
Random, Wait, 2000, 3500
Sleep, %Wait%
Catch := 1
}
else
{
ToolTips = 0
SetTimer, ToolTip, 500
Sleep, 500
}
}
}
}
Break := 1
ToolTips = 2
SetTimer, ToolTip, 500
return
!Numpad9::
Break := 1
ToolTip
return
Numpad7::
ExitApp
ToolTip:
If (ToolTips = 0)
ToolTip, Waiting.. %LureCount%/%Lure% Lures used, 0, 0
Else If (ToolTips = 1)
ToolTip, Catching Fish! %LureCount%/%Lure% Lures used, 0, 0
Else If (ToolTips = 2)
ToolTip, !!All Lure's Have Been Used!!, 0, 0
Return
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
}