I've gone into creating Autohotkey Script GUIs out of interest. I made a diagnostic tool of sorts, and one function of this tool is to give the user a constant, live update on their download speed in Kbps and Mbps using the netstat command.
I decided to use netstat because based on the individual machine setup, the adapter/connection interface can change, causing the tool to not work on all computers.
The only problem is when using Netstat, there's a delay in the update causing the progress bar data to hop back and fourth between "0" and the actual speed. (It kind of resets itself due to the delay with netstat data update)
The question I have is if there's a way to keep the data constant and accurate using the Netstat command, or if there's a more efficient way to get the result desired?
Here's part of the code:
#SingleInstance, Force
nstFile:="C:\bytes.txt"
Process Priority,,High
OnExit, exit
Gui, Show, h450 w500, Diagnostics
Gui, Font,
Gui, Add, Text, x200 y240, Live Network Activity:
Gui, Add, Progress, x131 y260 h100 w15 Vertical clime vbytesbar backgroundgray Range0-25
Gui, Add, Text, x105 y385 h15 vbytes, Loading...
Gui, Add, Text, x80 y370, Download Speed
Gui, Add, GroupBox, x320 y231 w115 h190 cblack
Gui, Font, s6
Gui, Add, Text, x92 y353, 0 Mbps -
Gui, Add, Text, x92 y334, 5 Mbps -
Gui, Add, Text, x90 y314, 10 Mbps -
Gui, Add, Text, x90 y295, 15 Mbps -
Gui, Add, Text, x90 y276, 20 Mbps -
Gui, Add, Text, x90 y255, 25 Mbps -
setTimer, updateBytes, 1000
updateBytes:
runWait %comspec% /c Netstat -e >"%nstFile%",,hide
fileReadLine,bytesLine,% nstFile,5
regExMatch(bytesLine,"Bytes\s+\K\d+",bytesData)
bandwidth:=bytesData-prevBytesData
prevBytesData:=bytesData
guiControl,text,bytes,% bandwidth//1000 " Kbps"
guiControl 1: , bytesbar,% bandwidth//1000000
Return
guiclose:
guiescape:
exit:
{
ifexist, C:\bytes.txt
FileDelete, C:\bytes.txt
}
{
exitapp
}
return
Thanks for your time and assistance.