#include <String.au3>
#include <GUIConstantsEx.au3>
$Form1 = GUICreate("显示统计", 200, 120, 445, 376)
$Label1 = GUICtrlCreateLabel("上传速度:", 24, 8, 55, 17)
$Label2 = GUICtrlCreateLabel("0", 88, 8, 100, 17)
$Label3 = GUICtrlCreateLabel("0", 88, 32, 100, 17)
$Label4 = GUICtrlCreateLabel("下载速度:", 24, 32, 55, 17)
$Label5 = GUICtrlCreateLabel("cpu使用率:", 24, 56, 80, 17)
$Label6 = GUICtrlCreateLabel("0", 88, 56, 100, 17)
$Label7 = GUICtrlCreateLabel("0", 108, 80, 130, 17)
$Label8 = GUICtrlCreateLabel("内存使用率:", 24, 80, 80, 17)
GUISetState(@SW_SHOW)
WinSetOnTop ($Form1,"",1)
$_IfTable=_GetIfTable()
Global $_Down=$_IfTable[0]
Global $_UpDate=$_IfTable[1]
Global $cpuvalus
Global $ramvalus
AdlibRegister ("_Strat_Time",500)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _Strat_Time()
$_IfTable=_GetIfTable()
$cpuvalus=_CPU()
$ramvalus=MemGetStats ( )
GUICtrlSetData ($Label2, Round(($_IfTable[1]-$_UpDate)/1024,2)& " Kb")
GUICtrlSetData ($Label3, Round(($_IfTable[0]-$_Down)/1024,2) & " Kb")
GUICtrlSetData ($Label6, $cpuvalus & "%")
GUICtrlSetData ($Label7, $ramvalus[1]-$ramvalus[2] & "KB")
Global $_Down=$_IfTable[0]
Global $_UpDate=$_IfTable[1]
EndFunc
Func _GetIfTable()
$_Return=DllCall("Iphlpapi.dll","long","GetIfTable","ptr",0,"ulong*",0,"int",0)
$_aBuffer=DllStructCreate("byte[" & $_Return[2] & "]")
$_Return=DllCall("Iphlpapi.dll","long","GetIfTable","ptr",DllStructGetPtr($_aBuffer),"ulong*",DllStructGetSize($_aBuffer),"int",0)
$_Number=DllStructCreate("dword",DllStructGetPtr($_aBuffer))
$_Number=DllStructGetData($_Number,1)
$_MIB_IFROW="dword" & _StringRepeat(";wchar[256];dword[5];byte[8];dword[16];byte[256]",$_Number)
$_MIB_IFTABLE=DllStructCreate($_MIB_IFROW,DllStructGetPtr($_aBuffer))
Dim $_Table[2]
For $i=2 To $_Number * 5 Step 5
$_Table[0]+=DllStructGetData($_MIB_IFTABLE,$i+3,4)
$_Table[1]+=DllStructGetData($_MIB_IFTABLE,$i+3,10)
Next
Return $_Table
EndFunc
Func _CPU()
$wbemServices = ObjGet("winmgmts:\\.\root\cimv2")
$wbemObjectSet= $wbemServices.ExecQuery("Select * from Win32_Processor")
For $wbemObject In $wbemObjectSet
$cpuvalus2=$wbemObject.LoadPercentage
Next
Return $cpuvalus2
EndFunc