1
+ #include < GUIConstants.au3>
2
+
3
+ GUICreate (" Lod3n's Bandwidth Monitor" ,220 ,100 ,0 ,0 ,- 1 ,$WS_EX_TOOLWINDOW )
4
+
5
+ $label1 = GUICtrlCreateLabel ( " Waiting for data..." , 10 , 5 ,200 ,20 )
6
+ $progressbar1 = GUICtrlCreateProgress (10 ,20 ,200 ,20 ,$PBS_SMOOTH )
7
+
8
+ $label2 = GUICtrlCreateLabel ( " Waiting for data..." , 10 , 50 ,200 ,20 )
9
+ $progressbar2 = GUICtrlCreateProgress (10 ,65 ,200 ,20 ,$PBS_SMOOTH )
10
+
11
+ GUISetState ()
12
+
13
+ $wbemFlagReturnImmediately = 0x10
14
+ $wbemFlagForwardOnly = 0x20
15
+ $colItems = " "
16
+ $strComputer = " localhost"
17
+ $objWMIService = ObjGet (" winmgmts:\\" & $strComputer & " \root\CIMV2" )
18
+
19
+ $inmax = 0
20
+ $outmax = 0
21
+
22
+ $lastin = 0
23
+ $lastout = 0
24
+
25
+ while 1
26
+ ; $colItems = $objWMIService.ExecQuery("SELECT BytesReceivedPersec,BytesSentPersec FROM Win32_PerfFormattedData_Tcpip_NetworkInterface", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
27
+ $colItems = $objWMIService .ExecQuery(" SELECT BytesReceivedPersec,BytesSentPersec FROM Win32_PerfRawData_Tcpip_NetworkInterface" , " WQL" , $wbemFlagReturnImmediately + $wbemFlagForwardOnly )
28
+
29
+ If IsObj ($colItems ) then
30
+ For $objItem In $colItems
31
+ $newin = $objItem .BytesReceivedPersec
32
+ $newout = $objItem .BytesSentPersec
33
+
34
+ ; new realtime counter code...
35
+ if $lastin = 0 and $lastout = 0 Then
36
+ $lastin = $newin
37
+ $lastout = $newout
38
+ endif
39
+ $in = $newin - $lastin
40
+ $out = $newout - $lastout
41
+ $lastin = $newin
42
+ $lastout = $newout
43
+
44
+ if $in <> 0 and $out <> 0 Then
45
+ if $in > $inmax then $inmax = $in
46
+ if $out > $outmax then $outmax = $out
47
+
48
+ $inP = int (($in / $inmax ) * 100 )
49
+ $outP = int (($out / $outmax ) * 100 )
50
+ ; $in = $in/1024
51
+ ; $out = $out/1024
52
+ $intext = " Bytes In/Sec: " & int ($in ) & " [" & $inP & " % of record]" & @CRLF
53
+ $outtext = " Bytes Out/Sec: " & int ($out ) & " [" & $outP & " % of record]" & @CRLF
54
+
55
+ GUICtrlSetData ($progressbar1 ,$inP )
56
+ GUICtrlSetData ($label1 ,$intext )
57
+ GUICtrlSetData ($progressbar2 ,$outP )
58
+ GUICtrlSetData ($label2 ,$outtext )
59
+
60
+ EndIf
61
+ ExitLoop ; I only care about the first network adapter, yo
62
+ Next
63
+ EndIf
64
+ sleep (1000 ) ; bytes PER SECOND
65
+ If GUIGetMsg () = $GUI_EVENT_CLOSE Then ExitLoop
66
+ WEnd
0 commit comments