Julius Ramos Posted January 3, 2006 Posted January 3, 2006 i want to create a script that monitor the cpu usage. but i dont know how to start. any can share there script is highly appreciated.. thank you in advanced. julius -----------------------------------------------------------BSECE, MCPAIM: juliusrmsYM: jivy_21@yahoo.comMSN: juliusLramos@hotmail.comMobile #: (Globe): +639167031989Web: http://www.trendmicro.com
Moderators SmOke_N Posted January 3, 2006 Moderators Posted January 3, 2006 (edited) I think gary wrote this... guess you could just do a filewrite() to log everything. $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") While 1 $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If Int($objItem.LoadPercentage) <> 100 Then ; do something here ToolTip("Your CPU Usage is: " & $objItem.LoadPercentage & "%", 0, 0) EndIf Sleep(1000) Next EndIf Sleep(100) WEnd Edited January 8, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Julius Ramos Posted January 3, 2006 Author Posted January 3, 2006 I think gary wrote this... guess you could just do a filewrite() to log everything. $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") While 1 $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If Int($objItem.LoadPercentage) <> 100 Then ; do something here ToolTip("Your CPU Usage is: " & $objItem.LoadPercentage & "%", 0, 0) EndIf Sleep(1000) Next EndIf Sleep(100) WEnd when i run this script i encountered an error.: Variable used without being declared.: $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly) $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL",^ ERROR -----------------------------------------------------------BSECE, MCPAIM: juliusrmsYM: jivy_21@yahoo.comMSN: juliusLramos@hotmail.comMobile #: (Globe): +639167031989Web: http://www.trendmicro.com
Julius Ramos Posted January 4, 2006 Author Posted January 4, 2006 what is the value of $wbemFlagReturnImmediately -----------------------------------------------------------BSECE, MCPAIM: juliusrmsYM: jivy_21@yahoo.comMSN: juliusLramos@hotmail.comMobile #: (Globe): +639167031989Web: http://www.trendmicro.com
Moderators SmOke_N Posted January 4, 2006 Moderators Posted January 4, 2006 what is the value of $wbemFlagReturnImmediatelyOh you have to guess that... Lmao... just kidding $wbemFlagReturnImmediately = 0x10 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Julius Ramos Posted January 4, 2006 Author Posted January 4, 2006 (edited) I think gary wrote this... guess you could just do a filewrite() to log everything. $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") While 1 $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If Int($objItem.LoadPercentage) <> 100 Then ; do something here ToolTip("Your CPU Usage is: " & $objItem.LoadPercentage & "%", 0, 0) EndIf Sleep(1000) Next EndIf Sleep(100) WEnd is this code support also win 9x ? Edited January 4, 2006 by Julius Ramos -----------------------------------------------------------BSECE, MCPAIM: juliusrmsYM: jivy_21@yahoo.comMSN: juliusLramos@hotmail.comMobile #: (Globe): +639167031989Web: http://www.trendmicro.com
Moderators SmOke_N Posted January 4, 2006 Moderators Posted January 4, 2006 I don't know.. have you tried it to see? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
rakudave Posted January 8, 2006 Posted January 8, 2006 sorry for bothering you, but i get $wbemFlagReturnImmediately is undeclared -> ??? Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table
Moderators SmOke_N Posted January 8, 2006 Moderators Posted January 8, 2006 Hmmm, didn't look at the whole post ? It was a bad copy and paste on my behalf... I'll edit the other one now.http://www.autoitscript.com/forum/index.ph...ndpost&p=136885 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
rakudave Posted January 8, 2006 Posted January 8, 2006 /me bangs his head against a wall Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table
Confuzzled Posted January 18, 2006 Posted January 18, 2006 is this code support also win 9x ? The code quoted relies on WMI functionality, which if I recall is not installed by default on Win9x machines by default.
SvenP Posted January 18, 2006 Posted January 18, 2006 See also this topic: http://www.autoitscript.com/forum/index.ph...11entry138811-Sven
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now