Jump to content

CHECK FOR CPU USAGE


victor
 Share

Recommended Posts

how to check for cpu usage ?

if mem is MemGetStats ( ) then what is cpu usage function ?

just curious

Here is some code I found a while back.

run("taskmgr.exe","",@SW_HIDE)
Sleep(1000)
while 1
$rc = StatusBarGetText("Windows Task Manager","",2)
Tooltip($rc,0,0)
sleep(10)
wend


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Run("taskmgr.exe", "", @SW_HIDE)
Sleep(1000)
While 1
    $rc = StringSplit(StringTrimRight(StatusbarGetText("Windows Task Manager", "", 2), 1), " ")
    $rc = Int($rc[$rc[0]])
    If $rc > 90 Then
    ; do something
        MsgBox(4096, "Above 90%", $rc)
    EndIf
    Sleep(10)
WEnd

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

if you have beta you could also do:

$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) > 90 Then
            ; do something here
                MsgBox(4096, "Above 90%", $objItem.LoadPercentage)
                Exit
            EndIf
        Next
    Else
        MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_Processor")
    EndIf
WEnd
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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