ProcessExist()

Auto Hotkey

ProcessExist

Checks if a process exists and returns its PID.

OutputVar := ProcessExist(PID-or-Name)
Function Example: PID := ProcessExist("AutoHotkey.exe")
OutputVar

The name of the variable in which to store the PID of found process.

PID-or-Name

This parameter can be either a number (the PID) or a process name as described below. It can also be left blank to get PID of the script itself.

PID: The Process ID, which is a number that uniquely identifies one specific process (this number is valid only during the lifetime of that process). The PID of a newly launched process can be determined via the Run command. Similarly, the PID of a window can be determined with WinGet.

Name: The name of a process is usually the same as its executable (without path), e.g. notepad.exe or winword.exe. Since a name might match multiple running processes, only the first process will be reported. The name is not case sensitive.

Remarks

Alternative method to retrieve the script's PID is PID := DllCall("GetCurrentProcessId").

Related

ProcessClose, ProcessSetPriority, ProcessWait , ProcessWaitClose, Run, WinGet, WinClose, WinKill, WinWait, WinWaitClose, WinExist

Examples

ProcessExist, OurPID  ; sets OurPID to the PID of this running script