pinkfoyd Posted July 31, 2006 Posted July 31, 2006 (edited) Hi all, i think my tittle was clear as for now, with autoit and the integrated function i can get the name and the PID of the process, but i need the cpu usage and the memory usage, does you have any solution ? thanks a lots ! Edited July 31, 2006 by pinkfoyd
Xenobiologist Posted July 31, 2006 Posted July 31, 2006 Hi, you need to show it, or to save it? Cause when you want to save the data I wonder what that turns out, because it changes every lets say second. Nevertheless, does the tasklist.exe of windows help? Or do you need it to be done via Autoit? So long, Mega 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
pinkfoyd Posted July 31, 2006 Author Posted July 31, 2006 (edited) Hi,you need to show it, or to save it? Cause when you want to save the data I wonder what that turns out, because it changes every lets say second. Nevertheless, does the tasklist.exe of windows help?Or do you need it to be done via Autoit?So long,Megathank for helpin th.megerPS : all what in fact, it's for use with LCD Smartie ( soft for control an LCD screen )I would writte on the screen certain process, like my web, FTP, and mail server for check all work wellexemple i would get the information each 15 minute for checking the process don't got to 100% ( hanging ) and ram up to high ( hanging too )hope you will understand mePS : "Nevertheless, does the tasklist.exe of windows help?" YES ! you right, i forgot this command, shame on me, now i have the memory use, but not the cpu usage of each process Edited July 31, 2006 by pinkfoyd
Xenobiologist Posted July 31, 2006 Posted July 31, 2006 HI, you could also have a look at MemGetStats() and While 1 Sleep(10) $cpu_usage = _Get_CPU_Usage(@ComputerName, 1, "taskmgr"); return usages if above the percent passed in If Not @error Then MsgBox(0, "CPU Usage", $cpu_usage) ExitLoop EndIf WEnd Func _Get_CPU_Usage($strComputer, $percent = 2, $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 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
pinkfoyd Posted July 31, 2006 Author Posted July 31, 2006 (edited) D:\Downloads\test.au3 (17) : ==> The requested action with this object has failed.: $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_PerfFormattedData_PerfProc_Process" & $strProcess, "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)^ ERROR +>AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 1.715 so bad ( latest beta ) EDIT : i have a french version of windows, it's the problem ? Edited July 31, 2006 by pinkfoyd
Xenobiologist Posted July 31, 2006 Posted July 31, 2006 Hi, I don't think so. Works for me. I have XP Sp1. :"> So long, Mega 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
pinkfoyd Posted July 31, 2006 Author Posted July 31, 2006 (edited) thanks a lot th.megerbut i found another way i just find this : http://www.teamcti.com/pview/prcview.htmand with the command line : pv explo* -o"%c - %m"it return the cpu usage (%c) and memory usage (%m) of the processus explorer.exe available info :Format string can use the following placeholders to control the output %a affinity, %d creation time, %c[time] % cpu %f full path, %e elapsed cpu time, %i process id %l command line, %n image name, %m memory (K) %p priority, %r parent id, %s signature %t thread count, %u user name, %v version Specify an optional performance data collecting time in milliseconds after the %c switch, default is 500ms. Edited July 31, 2006 by pinkfoyd
Gene Posted February 25, 2007 Posted February 25, 2007 HI, you could also have a look at MemGetStats() and While 1 Sleep(10) $cpu_usage = _Get_CPU_Usage(@ComputerName, 1, "taskmgr"); return usages if above the percent passed in If Not @error Then MsgBox(0, "CPU Usage", $cpu_usage) ExitLoop EndIf WEnd Func _Get_CPU_Usage($strComputer, $percent = 2, $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 Hi @th.meger I tried out the script above (curosity) It seemed to be very slow. My PC is 1.5Ghz, 256MbRAM, WinXP Pro. Attached is a graphic from my TaskManager Preformance tab while the script was running. The msgbox value was 50. [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...
Xenobiologist Posted February 25, 2007 Posted February 25, 2007 Hi, sorry there is nothing I can think of to speed it up. :"> So long, Mega 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
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