Added unit-scaling to read in network load values

This commit is contained in:
joten 2015-11-27 20:51:19 +01:00
parent 368144eb90
commit 02708be4f1
1 changed files with 46 additions and 27 deletions

View File

@ -30,31 +30,23 @@ ResourceMonitor_cleanup() {
DllCall("CloseHandle", "UInt", ResourceMonitor_hDrive) ;; used in ResourceMonitor_getDiskLoad DllCall("CloseHandle", "UInt", ResourceMonitor_hDrive) ;; used in ResourceMonitor_getDiskLoad
} }
ResourceMonitor_getText() { ResourceMonitor_bytesToString(b) {
Global Config_readinCpu, Config_readinDiskLoad, Config_readinMemoryUsage, Config_readinNetworkLoad If (b > 1047527424) {
b /= 1024 * 1024 * 1024
text := "" unit := "GB"
If Config_readinCpu } Else If (b > 1022976) {
text .= " CPU: " ResourceMonitor_getSystemTimes() "% " b /= 1024 * 1024
If Config_readinMemoryUsage { unit := "MB"
If (Config_readinCpu) } Else If (b > 999) {
text .= "|" b /= 1024
text .= " RAM: " ResourceMonitor_getMemoryUsage() "% " unit := "kB"
} Else {
unit := " B"
} }
If Config_readinDiskLoad { b := Round(b, 1)
If (Config_readinCpu Or Config_readinMemoryUsage) If (b > 99.9 Or unit = " B")
text .= "|" b := Round(b, 0)
ResourceMonitor_getDiskLoad(rLoad, wLoad) Return, SubStr(" " b, -3) . unit
text .= " Dr: " rLoad "% | Dw: " wLoad "% "
}
If Config_readinNetworkLoad {
If (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad)
text .= "|"
ResourceMonitor_getNetworkLoad(upLoad, dnLoad)
text .= " UP: " upLoad " KB/s | dn: " dnLoad " KB/s "
}
Return, text
} }
ResourceMonitor_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus) { ResourceMonitor_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus) {
@ -64,7 +56,7 @@ ResourceMonitor_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus) {
MsgBox 16, Power Status, Can't get the power status... MsgBox 16, Power Status, Can't get the power status...
Return Return
} }
acLineStatus := NumGet(powerStatus, 0, "Char") acLineStatus := NumGet(powerStatus, 0, "Char")
batteryLifePercent := NumGet(powerStatus, 2, "Char") batteryLifePercent := NumGet(powerStatus, 2, "Char")
If acLineStatus = 0 If acLineStatus = 0
@ -117,8 +109,8 @@ ResourceMonitor_getNetworkLoad(ByRef upLoad, ByRef dnLoad) {
Global ResourceMonitor_networkInterface Global ResourceMonitor_networkInterface
ResourceMonitor_networkInterface.Refresh_ ResourceMonitor_networkInterface.Refresh_
dnLoad := SubStr(" " Round(ResourceMonitor_networkInterface.BytesReceivedPerSec / 1024), -3) dnLoad := ResourceMonitor_bytesToString(ResourceMonitor_networkInterface.BytesReceivedPerSec) . "/s"
upLoad := SubStr(" " Round(ResourceMonitor_networkInterface.BytesSentPerSec / 1024), -3) upLoad := ResourceMonitor_bytesToString(ResourceMonitor_networkInterface.BytesSentPerSec) . "/s"
} }
;; Pillus: System monitor (HDD/Wired/Wireless) using keyboard LEDs (http://www.autohotkey.com/board/topic/65308-system-monitor-hddwiredwireless-using-keyboard-leds/) ;; Pillus: System monitor (HDD/Wired/Wireless) using keyboard LEDs (http://www.autohotkey.com/board/topic/65308-system-monitor-hddwiredwireless-using-keyboard-leds/)
@ -136,3 +128,30 @@ ResourceMonitor_getSystemTimes() {
Return, sysTime ;; system time in percent Return, sysTime ;; system time in percent
} }
;; Sean: CPU LoadTimes (http://www.autohotkey.com/forum/topic18913.html) ;; Sean: CPU LoadTimes (http://www.autohotkey.com/forum/topic18913.html)
ResourceMonitor_getText() {
Global Config_readinCpu, Config_readinDiskLoad, Config_readinMemoryUsage, Config_readinNetworkLoad
text := ""
If Config_readinCpu
text .= " CPU: " ResourceMonitor_getSystemTimes() "% "
If Config_readinMemoryUsage {
If (Config_readinCpu)
text .= "|"
text .= " RAM: " ResourceMonitor_getMemoryUsage() "% "
}
If Config_readinDiskLoad {
If (Config_readinCpu Or Config_readinMemoryUsage)
text .= "|"
ResourceMonitor_getDiskLoad(rLoad, wLoad)
text .= " Dr: " rLoad "% | Dw: " wLoad "% "
}
If Config_readinNetworkLoad {
If (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad)
text .= "|"
ResourceMonitor_getNetworkLoad(upLoad, dnLoad)
text .= " UP: " upLoad " | dn: " dnLoad " "
}
Return, text
}