Method wnd.findOrRun
Overload
Finds a top-level window, like wnd.find. If found, activates (optionally), else calls callback function and waits for the window. The callback should open the window, for example call run.it.
public static wnd findOrRun(string name = null, string cn = null, WOwner of = default, WFlags flags = 0, Func<wnd, bool> also = null, WContains contains = default, Action run = null, Seconds? wait = null, bool activate = true)
Parameters
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:
|
run (Action)
Callback function. See example. |
wait (Seconds?)
How long to wait for the window after calling the callback function. Seconds. Default 60. |
activate (bool)
Activate the window. Default: |
Returns
wnd
Window handle as wnd. On timeout returns |
Exceptions
NotFoundException
wait time has expired (if >= 0). |
AuWndException
Failed to activate. |
ArgumentException
|
Examples
wnd w = wnd.findOrRun("* Notepad", run: () => run.it("notepad.exe"));
print.it(w);