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. If a name matches multiple running processes, each is waited on until no match remains. The name is not case-sensitive.

Timeout

Type: Integer or Float

If omitted, the function will wait indefinitely. Otherwise, specify the number of seconds (can contain a decimal point) to wait before timing out. Zero or a negative value checks once without waiting.

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

A found process is waited on until it exits. If the operating system does not allow waiting on that process, it is checked every 100 milliseconds instead; 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.

While waiting for a found process to exit, timers, hotkeys and the GUI remain responsive. The timeout covers the entire wait when several processes share the name.

ProcessWait, Run, WinWaitClose, Process functions, Win functions

Examples

See example #1 on the ProcessWait page.