smirnoff Posted August 17, 2006 Share Posted August 17, 2006 (edited) Hi, in fac i've 2 questions, first, i wanan know cpu usage of one soft and kill it if its less than 5%i've found this and modifyRun("I:\mangos\mangosd.exe", "I:\mangos", @SW_MINIMIZE)Sleep(1000)While 1 $rc = StringSplit(StringTrimRight(StatusbarGetText("WHAT MUST I PUT HERE?", "", 2), 1), " ") $rc = Int($rc[$rc[0]]) If $rc < 5 Then ProcessClose("mangosd.exe") $PID = ProcessExists("mangosd.exe") ; If $PID Then ProcessClose($PID) EndIf Sleep(10)If Not ProcessExists ( "realmd.exe" ) Then RunWait ( "I:\mangos\realmd.exe", "I:\mangos", @SW_MINIMIZE )EndIfWEndIS it correct? if the CPu usage of the soft i wanna launch is less than 5 % it kill it, and after relaunch it?So the program must check the cpu usage of mangosd.exe, if less than 5%, kill and restart it, and in the second way, check for realmd.exe exist, if not, launch it ...Is it correct?thanks in advance Edited August 17, 2006 by smirnoff Link to comment Share on other sites More sharing options...
AceLoc Posted August 17, 2006 Share Posted August 17, 2006 title [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 17, 2006 Share Posted August 17, 2006 (edited) HI, maybe this helps further: $process = "scite" While 1 Sleep(10) $cpu_usage = _Get_CPU_Usage(@ComputerName, 5, $process); return usages if above the percent passed in If Not @error Then MsgBox(0, "CPU Usage of " & $process, $cpu_usage) ExitLoop EndIf WEnd Func _Get_CPU_Usage($strComputer, $percent = 5, $strProcess = "") $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" If $strProcess <> "" Then $strProcess = " WHERE Name = '" & $strProcess & "'" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_PerfFormattedData_PerfProc_Process" & $strProcess, "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If Number($objItem.PercentProcessorTime) > Number($percent) Then Return $objItem.PercentProcessorTime Next EndIf SetError(1) Return "" EndFunc ;==>_Get_CPU_Usage So long, Mega Edited August 17, 2006 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
smirnoff Posted August 17, 2006 Author Share Posted August 17, 2006 for the help, already read that but my AutoID refuse to compil this code ... dunno why, error in WMI ... must i need the beta ? Link to comment Share on other sites More sharing options...
smirnoff Posted August 17, 2006 Author Share Posted August 17, 2006 (edited) title What about title? its a DOS window ... so Title is tha path? "I:\mangos\mangosd.exe" ? exact? Edited August 17, 2006 by smirnoff Link to comment Share on other sites More sharing options...
AceLoc Posted August 17, 2006 Share Posted August 17, 2006 (edited) $rc = StringSplit(StringTrimRight(StatusbarGetText("WHAT MUST I PUT HERE?", "", 2), 1), " ");you must put the Title there.EDIT:well use the AutoIt Window Info thingy ! Edited August 17, 2006 by aceloc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
smirnoff Posted August 17, 2006 Author Share Posted August 17, 2006 ok now it work fine, thanks u 2 Link to comment Share on other sites More sharing options...
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