#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\Personal\Desktop\CPU_RAM.kxf
$FormName="System"
$Form1 = GUICreate($FormName, 306, 70, 193, 125, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_POPUP,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("CPU", 8, 8, 36, 17)
GUICtrlSetFont(-1, 11, 400, 0, "宋体")
$Label2 = GUICtrlCreateLabel("RAM", 8, 40, 36, 17)
GUICtrlSetFont(-1, 11, 400, 0, "宋体")
$Progress1 = GUICtrlCreateProgress(56, 8, 193, 17)
$Progress2 = GUICtrlCreateProgress(56, 40, 193, 17)
$Label3 = GUICtrlCreateLabel("", 264, 8, 36, 20)
GUICtrlSetFont(-1, 11, 400, 0, "宋体")
$Label4 = GUICtrlCreateLabel("", 264, 40, 36, 17)
GUICtrlSetFont(-1, 11, 400, 0, "宋体")
$pos = WinGetPos($FormName)
WinMove($FormName, "", @DesktopWidth / 2 - $pos[2] / 2, @DesktopHeight / 2 - $pos[3] / 2)
WinSetOnTop($FormName,"",1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
AdlibEnable("CpuRamRate",500)
While 1
WEnd
Func CpuRamRate()
Local $rCPU,$rRAM
$rCPU=CurrentCPURate()
$rRAM=CurrentRAMRate()
GUICtrlSetData($Progress1,$rCPU)
GUICtrlSetData($Label3,$rCPU&"%")
GUICtrlSetData($Progress2,$rRAM)
GUICtrlSetData($Label4,$rRAM&"%")
EndFunc
Func CurrentCPURate()
$wbemServices = ObjGet("winmgmts:\\.\root\cimv2")
$wbemObjectSet= $wbemServices.ExecQuery("Select * from Win32_Processor")
For $wbemObject In $wbemObjectSet
$dd=$wbemObject.LoadPercentage
Next
Return $dd
EndFunc
Func CurrentRAMRate()
Local $Array[7]
$Array=MemGetStats()
Return $Array[0]
EndFunc
随手写了个GUI界面,附带内存使用率,贡献给论坛吧~~呵呵 |