While 1
ToolTip("当前流量为:" & liuliang() & " 字节/秒", @DesktopWidth - 150, @DesktopHeight - 50)
WEnd
Func liuliang()
While 1
$s1=0
$s2=0
$strComputer = "."
$wbemServices = ObjGet("winmgmts:\" & $strComputer & "\root\cimv2")
$wbemObjectSet= $wbemServices.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface")
For $wbemObject In $wbemObjectSet
$s1=$s1+$wbemObject.BytesReceivedPerSec
Next
sleep(1000)
$strComputer = "."
$wbemServices = ObjGet("winmgmts:\" & $strComputer & "\root\cimv2")
$wbemObjectSet= $wbemServices.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface")
For $wbemObject In $wbemObjectSet
$s2=$s2+$wbemObject.BytesReceivedPerSec
Next
$dd=$s2-$s1
;~ MsgBox(1,"提示","每秒流量:"&$dd,10)
Return $dd
sleep(20)
WEnd
EndFunc
|