ProcessWaitClose

Waits for all matching processes to close.

PID := ProcessWaitClose(PIDOrName , Timeout)

Parameters

PIDOrName

Type: Integer or String

Specify either a number (the PID) or a process name:

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 function. Similarly, the PID of a window can be determined with WinGetPID. ProcessExist can also be used to discover a PID.

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 operated upon. The name is not case sensitive.

Timeout

Type: Integer or Float

If omitted, this function will wait indefinitely. Otherwise, specify the number of seconds (can contain a decimal point) to wait before timing out.

Return Value

Type: Integer

If all matching processes are closed, zero is returned. If this function times out, it returns the Process ID (PID) of the first matching process that still exists.

Remarks

Processes are checked every 100 milliseconds; the moment the condition is satisfied, the function stops waiting. In other words, rather than waiting for the timeout to expire, it immediately returns and continues execution of the script. Also, while the function is in a waiting state, new threads can be launched via hotkey, custom menu item, or timer.

Related

ProcessWait, Run, WinWaitClose, Process functions, Win functions

Examples

See example #1 on the ProcessWait page.