Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get process memory usage?

I have been searching for how to get processes memory usage, is this possible using only an AutoHotkey script?

If someone could point where to start, thanks.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

How about this function?

GetProcessMemoryInfo(PID) {
    size := 440
    VarSetCapacity(pmcex,size,0)
    ret := ""
    
    hProcess := DllCall( "OpenProcess", UInt,0x400|0x0010,Int,0,Ptr,PID, Ptr )
    if (hProcess)
    {
        if (DllCall("psapi.dll\GetProcessMemoryInfo", Ptr, hProcess, Ptr, &pmcex, UInt,size))
            ret := NumGet(pmcex, (A_PtrSize=8 ? "16" : "12"), "UInt")/1024 . " K"
        DllCall("CloseHandle", Ptr, hProcess)
    }
    return % ret
}

Taken from AHK_Task Manager:
https://www.autohotkey.com/board/topic/79151-ahk-task-manager/

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading