Process Functions

Functions for retrieving information about a process or for performing various operations on a process. Click on a function name for details.

Function Description
ProcessClose Forces the first matching process to close.
ProcessExist Checks if the specified process exists.
ProcessGetName Returns the name of the specified process.
ProcessGetParent Returns the process ID (PID) of the process which created the specified process.
ProcessGetPath Returns the path of the specified process.
ProcessSetPriority Changes the priority level of the first matching process.
ProcessWait Waits for the specified process to exist.
ProcessWaitClose Waits for all matching processes to close.

Remarks

Process list: Although there is no ProcessList function, example #1 and example #2 demonstrate how to retrieve a list of processes via DllCall or COM.

Run, WinClose, WinKill, WinWait, WinWaitClose, WinExist, Win functions

Examples

Shows a list of running processes retrieved via DllCall and EnumProcesses.

MyGui := Gui()
LV := MyGui.Add("ListView", "w1300 r25", ["#", "PID", "Name", "Path"])
for Index, Proc in GetProcessList()
    LV.Add("", Index, Proc.PID, Proc.Name, Proc.Path)
LV.ModifyCol()
MyGui.Title := LV.GetCount() " Processes"
MyGui.Show()

GetProcessList(MaxProcs := 1024) {
    Arr := []  ; array to store the process information
    DllCall("Psapi.dll\EnumProcesses"
        , "Ptr", Buf := Buffer(MaxProcs * 4)  ; buffer to store all PIDs
        , "UInt", Buf.Size
        , "UIntP", &ByteCnt := 0)  ; number of bytes returned by DllCall
    Loop (ByteCnt // 4) {
        PID := NumGet(Buf, (A_Index - 1) * 4, "UInt")
        try Arr.Push({
            Name: ProcessGetName(PID),
            Path: ProcessGetPath(PID),
            PID: PID
        })
    }
    return Arr
}

Shows a list of running processes retrieved via COM and Win32_Process.

MyGui := Gui(, "Process List")
LV := MyGui.Add("ListView", "x2 y0 w400 h500", ["Process Name", "Command Line"])
for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")
    LV.Add("", process.Name, process.CommandLine)
MyGui.Show()