Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance force
- #Include AutoHotkeyMemoryLib.ahk
- SetBatchLines, -1
- DetectHiddenWindows, On
- cliname=Path of Exile
- cliexe=PathOfExile.exe
- autoPotionsWatchdogPeriod:=10
- baseMgrPtr:= 0
- trayNotifications:= True
- basePtrAoBArray:=[0x53,0x55,0x56,0x57,0x33,0xFF,0x3B,0xC7]
- basePtrAobOffset:=-0x0A
- WindowBasicsCache:=[] ; keyed by "%hwnd%%CurrPid%", entries are objects with properties processHandle, moduleBase, moduleSize, baseFramePtr
- Loop
- {
- Main()
- }
- GetWindowBasics(hwnd, byref mB="", byref pH="", byref mS="")
- {
- global WindowBasicsCache
- global cliexe
- WinGet, CurrPid, PID, ahk_id %hwnd%
- k="%hwnd%%CurrPid%"
- mB:=WindowBasicsCache[k].mBase
- mS:=WindowBasicsCache[k].mSize
- if mB=
- {
- WindowBasicsCache[k]:=Object()
- GetModuleInfo(cliexe, CurrPid, mB, mS)
- if (mB="" || mS="")
- {
- MsgBox, Failed to obtain moduleBase or moduleSize for PID %CurrPid%, script will now terminate
- ExitApp
- }
- WindowBasicsCache[k].mBase:=mB
- WindowBasicsCache[k].mSize:=mS
- }
- pH:=WindowBasicsCache[k].ProcessHandle
- if pH=
- {
- pH:=GetProcessHandle(CurrPid)
- if (pH="" || pH=-1)
- {
- MsgBox, Invalid process handle obtained for PID %CurrPid%, script will now terminate
- ExitApp
- }
- WindowBasicsCache[k].ProcessHandle:=pH
- }
- }
- ScanBaseMgrPtr(mBase,pH,moduleSize)
- {
- global basePtrAoBArray
- global basePtrAobOffset
- global baseMgrPtr
- CoordMode, Tooltip, Screen
- ToolTip, PoE In Game Distance by Gurud, 0, 0
- aobResult:=AobScan(pH,mBase,moduleSize,basePtrAoBArray)
- if aobResult
- {
- SetFormat, IntegerFast, hex
- baseMgrPtr:=ReadMemUInt(pH,mBase+aobResult+basePtrAobOffset)-mBase
- if (trayNotifications)
- TrayTip, New Base Pointer Found, baseMgrPtr = %baseMgrPtr%
- GuiControl, , basePtrText, %baseMgrPtr%
- SetFormat, IntegerFast, dec
- CoordMode, Tooltip, Relative
- }
- else
- {
- MsgBox, baseMgrPtr not found with AoBScan, script will now terminate
- ExitApp
- }
- }
- GetFrameBase(hwnd)
- {
- global baseMgrPtr
- global WindowBasicsCache
- WinGet, CurrPid, PID, ahk_id %hwnd%
- k="%hwnd%%CurrPid%"
- fB:=WindowBasicsCache[k].fBase
- if fB=
- {
- GetWindowBasics(hwnd, mBase, pH, mSize)
- if baseMgrPtr= 0
- {
- ScanBaseMgrPtr(mBase, pH, mSize)
- }
- fB:=GetMultilevelPointer(pH,[mBase+baseMgrPtr,4,0x7C,0x94])
- WindowBasicsCache[k].fBase:=fB
- }
- return fB
- }
- ReadPlayerStats(hwnd, byRef PlayerStats)
- {
- GetWindowBasics(hwnd, mBase, pH)
- fBase:=GetFrameBase(hwnd)
- PlayerBase:=GetMultilevelPointer(pH,[fBase+0xBC,0x59C])
- PlayerBase2:=ReadMemUInt(pH,PlayerBase+0x24)
- PlayerStats.PosX:=ReadMemFloat(pH,PlayerBase2+0x2c)
- PlayerStats.PosY:=ReadMemFloat(pH,PlayerBase2+0x30)
- }
- IsInGame(hwnd)
- {
- if (hwnd=0 || hwnd="")
- return false
- GetWindowBasics(hwnd,mBase,pH)
- if (mBase="" || mBase=0 || pH="" || pH=-1)
- return false
- fBase:=GetFrameBase(hwnd)
- if (fBase="" || fBase=0)
- return false
- localConnection:=ReadMemUInt(pH,fBase+0xc0)
- if (localConnection=0 || localConnection="")
- return false
- else
- return true
- }
- MousePos(hwnd,ByRef x, ByRef y)
- {
- GetWindowBasics(hwnd,mBase,pH)
- if (mBase!=0 && pH && pH!=-1)
- {
- FrameBase:=GetFrameBase(hwnd)
- x:=ReadMemFloat(pH,FrameBase+0x16a4)
- y:=ReadMemFloat(pH,FrameBase+0x16a8)
- return true
- }
- }
- Main()
- {
- global autoPotionsWatchdogPeriod
- global lagCompensation
- global WindowQueuedFlaskEffects
- global cliname
- global cliexe
- global trayNotifications
- WinGet, WinID, List, %cliname%
- Loop, %WinID%
- {
- WinGet, ProcModuleName, ProcessName, % "ahk_id" WinID%A_Index%
- If(ProcModuleName!=cliexe) ; got a window with title "Path of Exile" but exe is not Client.exe, perhaps we have browser window open with PoE site, ignore it
- {
- ToolTip,, 0, 0
- continue
- }
- if (WinID%A_Index%=WinActive("A"))
- ThisID:=WinActive("A")
- WinGet, CurrPID, PID, % "ahk_id" WinID%A_Index%
- hwnd:=WinID%A_Index%
- if (!IsInGame(WinID%A_Index%)) ;not ingame
- {
- IfWinActive Path of Exile ahk_class Direct3DWindowClass
- {
- ToolTip, Waiting For Log In, 0, 0
- }
- Else
- {
- ToolTip,, 0, 0
- }
- }
- Else
- {
- IfWinActive Path of Exile ahk_class Direct3DWindowClass
- {
- CoordMode, Mouse, Relative
- MouseGetPos, mx, my
- PlayerStats:={}
- ReadPlayerStats(WinID%A_Index%, PlayerStats)
- MousePos(hwnd,MouseX, MouseY)
- If (MouseX >= PlayerStats.PosX)
- X_Dist:= (MouseX - PlayerStats.PosX)
- Else If (MouseX < PlayerStats.PosX)
- X_Dist:= (PlayerStats.PosX - MouseX)
- If (MouseY >= PlayerStats.PosY)
- Y_Dist:= (MouseY - PlayerStats.PosY)
- Else If MouseY < PlayerStats.PosY
- Y_Dist:= (PlayerStats.PosY - MouseY)
- Distance:= Round(Sqrt((X_Dist*X_Dist)+(Y_Dist*Y_Dist)),1)
- ToolTip, % Distance, mx + 10 , my
- }
- Else
- {
- ToolTip,, 0, 0
- }
- }
- }
- Sleep, %autoPotionsWatchdogPeriod%
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement