Jump to content

Recommended Posts

Posted

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
Posted (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 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.

Posted

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

  • Moderators
Posted

what is the value of $wbemFlagReturnImmediately

Oh you have to guess that... :P 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.

Posted (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 by Julius Ramos

-----------------------------------------------------------BSECE, MCPAIM: juliusrmsYM: jivy_21@yahoo.comMSN: juliusLramos@hotmail.comMobile #: (Globe): +639167031989Web: http://www.trendmicro.com

  • Moderators
Posted

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.

  • 2 weeks later...
Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...