Function Reference


ProcessList

Returns an array listing the currently running processes (names and PIDs).

ProcessList ( ["name"] )

Parameters

name [optional] If a name is given only processes of the same name will be returned.

Return Value

Success: an array of process names and PIDs (See Remarks).
Failure: sets the @error flag to 1 when the array cannot be built.

Remarks

The array returned is two-dimensional and is made up as follows:
$aArray[0][0] = Number of processes
$aArray[1][0] = 1st Process name
$aArray[1][1] = 1st Process ID (PID)
$aArray[2][0] = 2nd Process name
$aArray[2][1] = 2nd Process ID (PID)
...
$aArray[n][0] = nth Process name
$aArray[n][1] = nth Process ID (PID)

The list can be empty if $aArray[0][0] = 0. No @error set in this case.

Related

ProcessClose, ProcessExists, ProcessGetStats, ProcessSetPriority, ProcessWait, ProcessWaitClose, WinGetProcess

Example

#include <MsgBoxConstants.au3>
Example()
Func  Example()
; Run Notepad
Run ("notepad.exe")
; Wait 10 seconds for the Notepad window to appear.
Local $hWnd= WinWait ("[CLASS:Notepad]","",10)
; Display a list of Notepad processes returned by ProcessList.
Local $aProcessList= ProcessList ("notepad.exe")
For $i= 1To $aProcessList[0][0]
MsgBox ($MB_SYSTEMMODAL,"",$aProcessList[$i][0]&@CRLF &"PID: "&$aProcessList[$i][1])
Next
; Close the Notepad window using the handle returned by WinWait.
WinClose ($hWnd)
EndFunc ;==>Example

AltStyle によって変換されたページ (->オリジナル) /