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
- baseMgrPtr:= 0
- LastChatLogged:=
- 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 PM Logger by Gurud, 0, 0
- aobResult:=AobScan(pH,mBase,moduleSize,basePtrAoBArray)
- if aobResult
- {
- SetFormat, IntegerFast, hex
- baseMgrPtr:=ReadMemUInt(pH,mBase+aobResult+basePtrAobOffset)-mBase
- SetFormat, IntegerFast, dec
- CoordMode, Tooltip, Relative
- ToolTip,, 0, 0
- }
- 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
- }
- GetChatBase(hwnd)
- {
- global baseMgrPtr
- global WindowBasicsCache
- WinGet, CurrPid, PID, ahk_id %hwnd%
- k="%hwnd%%CurrPid%"
- uB:=WindowBasicsCache[k].uBase
- if uB=
- {
- GetWindowBasics(hwnd, mBase, pH, mSize)
- if baseMgrPtr= 0
- {
- ScanBaseMgrPtr(mBase, pH, mSize)
- }
- uB:=ReadMemUInt(ph,mBase+baseMgrPtr)
- WindowBasicsCache[k].uBase:=uB
- }
- return uB
- }
- ReadPlayerStats(hwnd, byRef PlayerStats)
- {
- GetWindowBasics(hwnd, mBase, pH)
- fBase:=GetFrameBase(hwnd)
- ChatBase:=GetChatBase(hwnd)
- LastChatStr:=ReadMemStr(ph,ChatBase+0xD508,255,"UTF-8")
- PlayerBase:=GetMultilevelPointer(pH,[fBase+0xBC,0x59C])
- PlayerMain:=ReadMemUInt(pH,PlayerBase+4)
- If (ReadMemUInt(pH, ReadMemUInt(pH,PlayerMain+0x14)+0x24)<8) ;names shorter than 7 chars are stored immediately in component
- {
- PlayerStats.Name:=ReadMemStr(pH, ReadMemUint(pH,PlayerMain+0x14)+0x10,100,"UTF-16") ;immediate name in component
- }
- Else
- {
- PlayerStats.Name:=ReadMemStr(pH, GetMultilevelPointer(pH,[PlayerMain+0x14,0x10]),100,"UTF-16") ; otherwise pointer to name is stored
- }
- Loop, Parse, LastChatStr, `n, `r
- {
- If A_Index = 1
- {
- IfInString, A_LoopField, @
- {
- PlayerStats.LastChatStr:=A_LoopField
- PlayerStats.ChatDate:=SubStr(A_LoopField, 1, 10)
- PlayerStats.ChatTime:=SubStr(A_LoopField, 12, 8)
- StringGetPos, PositionName, A_LoopField,@
- PositionNameEnd:= InStr(A_LoopField, ":" , CaseSensitive = false, StartingPos = PositionName)
- PlayerStats.ChatMsg:=SubStr(A_LoopField, PositionName, 255)
- PlayerStats.ChatName:=SubStr(A_LoopField, (PositionName+2), (PositionNameEnd-(PositionName+2)))
- }
- }
- Break
- }
- }
- 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
- }
- Main()
- {
- global cliname
- global cliexe
- 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%)) ;if not in game
- {
- Sleep, 100
- }
- Else
- {
- PlayerStats:={}
- ReadPlayerStats(WinID%A_Index%, PlayerStats)
- If (PlayerStats.LastChatStr!=LastChatLogged)
- {
- LastChatLogged:=PlayerStats.LastChatStr
- ;-----AFTER NEW PM SCRIPT WILL EXUCUTE LINES BELOW ONCE------;
- ;PlayerStats.ChatMsg contains "@PlayerName: MSG"
- ;PlayeStats.ChatName constains "PlayerName"
- ;PlayerStats.ChatDate contains "YEAR/MONTH/DAY"
- ;PlayerStats.ChatTime contains "HOUR:MIN:SEC"
- ;PlayerStats.Name contains "YourPlayerName"
- ;Linked Items will appear as "_"
- IniWrite, % " " PlayerStats.ChatMsg, PMLog.ini,% PlayerStats.ChatDate, % PlayerStats.ChatTime " "
- ;-----AFTER NEW PM SCRIPT WILL EXUCUTE LINES ABOVE ONCE------;
- }
- }
- Sleep, 10
- }
- Sleep, 10
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement