oleg Posted February 25, 2006 Share Posted February 25, 2006 (edited) Got this script and the second For executed only once Can somebody explain why so i could get a brighter view on that ?For $objProcess in $colProcesses $ProcessName = $objProcess.Name $ProcessId = $objProcess.ProcessId $ProcessPriority = $objProcess.Priority $ProcessMemUsage = $objProcess.WorkingSetSize $objProcess.GetOwner ($Owner) $ProcessMemUsage = ($ProcessMemUsage / 1024) / 1024 $ProcessMemUsage = Round($ProcessMemUsage, 1) $cpuProcs = $objWMIService.ExecQuery("Select * from Win32_PerfFormattedData_PerfProc_Process where name ='"& $objProcess.Name & "'") For $obj In $cpuProcs $Processcpu = $obj.name Next $LISTITEM = GUICtrlCreateListViewItem($ProcessName & "|" & $ProcessId & "|" & $ProcessMemUsage & " MB" & "|" & $Processcpu & "|" & $ProcessPriority & "|" & $Owner, $PSLIST) Next Edited February 25, 2006 by oleg There is a hex ( 31303030303030 ) reasons i love AutoIt ! Link to comment Share on other sites More sharing options...
GaryFrost Posted February 25, 2006 Share Posted February 25, 2006 (edited) take a look at your select statement, your selecting only one process would be my guess, there for only 1 literation thru the loop Edited February 25, 2006 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 More sharing options...
oleg Posted February 25, 2006 Author Share Posted February 25, 2006 (edited) Got this script and the second For executed only once Can somebody explain why so i could get a brighter view on that ?Yes you right in the second for i select one process and that is what i want but isnt after that first for continues but dose not enter second no more Example $colProcesses = $objWMIService.ExecQuery ( "Select * from Win32_Process", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) Dim $Processcpu For $objProcess in $colProcesses $ProcessName = $objProcess.Name $ProcessId = $objProcess.ProcessId $ProcessPriority = $objProcess.Priority $ProcessMemUsage = $objProcess.WorkingSetSize $objProcess.GetOwner ($Owner) $ProcessMemUsage = ($ProcessMemUsage / 1024) / 1024 $ProcessMemUsage = Round($ProcessMemUsage, 1) $cpuProcs = $objWMIService.ExecQuery("Select * from Win32_PerfFormattedData_PerfProc_Process where name ='"& $objProcess.Name & "'")This message box appears for each process selected by first for > MsgBox(0,"", $objProcess.Name)For $obj In $cpuProcsThis message box appears only once and display first matched process selected from first for > MsgBox(0,"",$obj.name) $Processcpu = $obj.name Next $LISTITEM = GUICtrlCreateListViewItem($ProcessName & "|" & $ProcessId & "|" & $ProcessMemUsage & " MB" & "|" & $Processcpu & "|" & $ProcessPriority & "|" & $Owner, $PSLIST) Next Edited February 25, 2006 by oleg There is a hex ( 31303030303030 ) reasons i love AutoIt ! Link to comment Share on other sites More sharing options...
GaryFrost Posted February 25, 2006 Share Posted February 25, 2006 (edited) what your selecting on won't work, try the ProcessId for example: $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colProcesses = $objWMIService.ExecQuery ( "Select * from Win32_Process", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) Dim $Processcpu For $objProcess In $colProcesses ConsoleWrite("Name: " & $objProcess.Name & @LF) ConsoleWrite("Caption: " & $objProcess.Caption & @LF) ConsoleWrite("Description: " & $objProcess.Description & @LF) ConsoleWrite("ProcessId: " & $objProcess.ProcessId & @LF) $ProcessName = $objProcess.Name $ProcessId = $objProcess.ProcessId $ProcessPriority = $objProcess.Priority $ProcessMemUsage = $objProcess.WorkingSetSize ;~ $objProcess.GetOwner ($Owner) $ProcessMemUsage = ($ProcessMemUsage / 1024) / 1024 $ProcessMemUsage = Round($ProcessMemUsage, 1) $cpuProcs = "" $cpuProcs = $objWMIService.ExecQuery ("Select * from Win32_PerfFormattedData_PerfProc_Process where IDProcess ='" & $objProcess.ProcessId & "'", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) $Processcpu = "" $IDProcess = "" For $obj In $cpuProcs $Processcpu = $obj.Name $IDProcess = $obj.IDProcess Next MsgBox(0,"test",$ProcessName & @LF & $Processcpu) ;~ $LISTITEM = GUICtrlCreateListViewItem($ProcessName & "|" & $ProcessId & "|" & $ProcessMemUsage & " MB" & "|" & $Processcpu & "|" & $ProcessPriority & "|" & $Owner, $PSLIST) Next Edited February 25, 2006 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 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