Method wnd.wait
Overload
Waits until window exists or is active.
public static wnd wait(Seconds timeout, bool active, string name = null, string cn = null, WOwner of = default, WFlags flags = 0, Func<wnd, bool> also = null, WContains contains = default)
Parameters
timeout (Seconds)
Timeout, seconds. Can be 0 (infinite), >0 (exception) or <0 (no exception). More info: Wait timeout. |
active (bool)
The window must be the active window (wnd.active), and not minimized. |
name (string)
Window name. Usually it is the title bar text.
String format: wildcard expression.
|
cn (string)
Window class name.
String format: wildcard expression.
|
of (WOwner)
Owner window, program or thread. Depends on argument type:
See wnd.getwnd.Owner, wnd.ProcessId, process.thisProcessId, wnd.ThreadId, process.thisThreadId. |
flags (WFlags) |
also (Func<wnd, bool>)
Callback function. Called for each matching window.
It can evaluate more properties of the window and return |
contains (WContains)
Defines an object that must be in the client area of the window:
|
Returns
wnd
Window handle. On timeout returns |
Exceptions
TimeoutException
timeout time has expired (if > 0). |
ArgumentException |
Remarks
Parameters etc are the same as wnd.find. By default ignores invisible and cloaked windows. Use flags if need. If you have a window's wnd variable, to wait until it is active/visible/etc use wnd.WaitFor<T> instead.
Examples
wnd w = wnd.wait(10, false, "* Notepad");
print.it(w);
Using in a WPF window with async/await.
using System.Windows;
var b = new wpfBuilder("Window").WinSize(250);
b.R.AddButton("Wait", async _ => {
print.it("waiting for Notepad...");
wnd w = await Task.Run(() => wnd.wait(-10, false, "* Notepad"));
if(w.Is0) print.it("timeout"); else print.it(w);
});
if (!b.ShowDialog()) return;