Sign in to follow this  
Followers 0
victor

CHECK FOR CPU USAGE

5 posts in this topic

#1 ·  Posted (edited)

how to check for cpu usage ?

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

just curious

Edited by victor

Share this post


Link to post
Share on other sites



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


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

thanks , but I want the exact number or percentage. so that i can use operator on the number.

say like

if cpu usage > 90% then do something ?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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.

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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.

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0