Skip to content

Instantly share code, notes, and snippets.

@sidola
Created May 4, 2014 07:26
Show Gist options
  • Select an option

  • Save sidola/11512117 to your computer and use it in GitHub Desktop.

Select an option

Save sidola/11512117 to your computer and use it in GitHub Desktop.
AHK - Get the current CPU load
CPULoad() { ; By SKAN / 22-Apr-2014. Thanks to ejor, Codeproject: http://goo.gl/epYnkO
Static GetSystemTimes, PIT, PKT, PUT ; Note > vars Pxx is Previous and Cxx is Current
If ! GetSystemTimes
GetSystemTimes := DllCall( "GetProcAddress", UInt, DllCall( "GetModuleHandle"
, Str,"Kernel32.dll" ), A_IsUnicode ? "AStr" : "Str","GetSystemTimes" )
, DllCall( GetSystemTimes, Int64P,PIT, Int64P,PKT, Int64P,PUT )
DllCall( GetSystemTimes, Int64P,CIT, Int64P,CKT, Int64P,CUT )
, IdleTime := PIT - CIT, KernelTime := PKT - CKT, UserTime := PUT - CUT
, SystemTime := KernelTime + UserTime
Return ( ( SystemTime - IdleTime ) * 100 // SystemTime ), PIT:=CIT, PKT:=CKT, PUT:=CUT
} ; http://ahkscript.org/boards/viewtopic.php?p=17166#p17166
@Bluscream
Copy link
Copy Markdown

Does not work anymore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment