Mharr
Wanted Pirate
I wrote this AutoHotkey script back before the major update when the client was springing memory leaks all over and crashing during single solo voyages, to let me know when it was time to port and relog. Given that crewing seems to have some of the same problems atm, and is important for collecting upgrade materials, I thought it might be useful.
Compiled version here.
Updated to use Brioso Pro Regular piratey font. (Optional)
Updated to react to changes in screen resolution.
Change top and right to adjust the position of the memory display in screen percentages.
Memory usage functions courtesy of Wade Hatler.
Compiled version here.
Updated to use Brioso Pro Regular piratey font. (Optional)
Updated to react to changes in screen resolution.
Change top and right to adjust the position of the memory display in screen percentages.
Code:
#Singleinstance, Force
top := 23
right := 0
varSetCapacity(spaces,64,asc(" "))
Gui +E0x20 +LastFound +AlwaysOnTop +ToolWindow -Caption -Border
Gui, Color, 000000
WinSet, TransColor, 000000
Gui, Margin, 0, 0
Gui, Font, S16 CFFFFFF, Brioso Pro Regular
Gui, Add, Text, C00FF00 BackgroundTrans vT1, %spaces%
Gui, Add, Text, CFFFF00 BackgroundTrans xp yp vT2, %spaces%
Gui, Add, Text, CFF0000 BackgroundTrans xp yp vT3, %spaces%
SetTimer, Update, 4000
Update:
POs_x := A_Screenwidth * (100 - right) / 100 - 80
pos_y := A_Screenheight * top / 100
Gui, Show, x%pos_x% y%pos_y%
memory := GetProcessMemory_Private("tlopo.exe", "M")
if (memory > 0 && memory < 1200)
{
GuiControl,, T1, %memory% MB
GuiControl,, T2, %spaces%
GuiControl,, T3, %spaces%
}
if (memory >= 1200 && memory < 1600)
{
GuiControl,, T1, %spaces%
GuiControl,, T2, %memory% MB
GuiControl,, T3, %spaces%
}
if (memory >= 1600)
{
GuiControl,, T1, %spaces%
GuiControl,, T2, %spaces%
GuiControl,, T3, %memory% MB
}
Return
;=============================================================================================================
; Func: GetProcessMemory_Private
; Get the number of private bytes used by a specified process. Result is in K by default, but can also be in
; bytes or MB.
;
; Params:
; ProcName - Name of Process (e.g. Firefox.exe)
; Units - Optional Unit of Measure B | K | M. Defaults to K (Kilobytes)
;
; Returns:
; Private bytes used by the process
;-------------------------------------------------------------------------------------------------------------
GetProcessMemory_Private(ProcName, Units="K") {
Process, Exist, %ProcName%
pid := Errorlevel
; get process handle
hProcess := DllCall( "OpenProcess", UInt, 0x10|0x400, Int, false, UInt, pid )
; get memory info
PROCESS_MEMORY_COUNTERS_EX := VarSetCapacity(memCounters, 44, 0)
DllCall( "psapi.dll\GetProcessMemoryInfo", UInt, hProcess, UInt, &memCounters, UInt, PROCESS_MEMORY_COUNTERS_EX )
DllCall( "CloseHandle", UInt, hProcess )
SetFormat, Float, 0.0 ; round up K
PrivateBytes := NumGet(memCounters, 40, "UInt")
if (Units == "B")
return PrivateBytes
if (Units == "K")
Return PrivateBytes / 1024
if (Units == "M")
Return PrivateBytes / 1024 / 1024
}
;=============================================================================================================
; Func: GetProcessMemory_All
; Get all Process Memory Usage Counters. Mimics what's shown in Task Manager.
;
; Params:
; ProcName - Name of Process (e.g. Firefox.exe)
;
; Returns:
; String with all values in KB as one big string. Use a Regular Expression to parse out the value you want.
;-------------------------------------------------------------------------------------------------------------
GetProcessMemory_All(ProcName) {
Process, Exist, %ProcName%
pid := Errorlevel
; get process handle
hProcess := DllCall( "OpenProcess", UInt, 0x10|0x400, Int, false, UInt, pid )
; get memory info
PROCESS_MEMORY_COUNTERS_EX := VarSetCapacity(memCounters, 44, 0)
DllCall( "psapi.dll\GetProcessMemoryInfo", UInt, hProcess, UInt, &memCounters, UInt, PROCESS_MEMORY_COUNTERS_EX )
DllCall( "CloseHandle", UInt, hProcess )
list := "cb,PageFaultCount,PeakWorkingSetSize,WorkingSetSize,QuotaPeakPagedPoolUsage"
. ",QuotaPagedPoolUsage,QuotaPeakNonPagedPoolUsage,QuotaNonPagedPoolUsage"
. ",PagefileUsage,PeakPagefileUsage,PrivateUsage"
n := 0
Loop, Parse, list, `,
{
n += 4
SetFormat, Float, 0.0 ; round up K
this := A_Loopfield
this := NumGet( memCounters, (A_Index = 1 ? 0 : n-4), "UInt") / 1024
; omit cb
If A_Index != 1
info .= A_Loopfield . ": " . this . " K" . ( A_Loopfield != "" ? "`n" : "" )
}
Return "[" . pid . "] " . pname . "`n`n" . info ; for everything
}
Memory usage functions courtesy of Wade Hatler.
Last edited: