Created
May 4, 2014 07:26
-
-
Save sidola/11512117 to your computer and use it in GitHub Desktop.
AHK - Get the current CPU load
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does not work anymore?