Method wnd.IsMatch(+ 1 overload)
Overload
Compares window name and other properties like wnd.find does.
public bool IsMatch(string name = null, string cn = null, WOwner of = default, WFlags flags = 0, Func<wnd, bool> also = null, WContains contains = default)
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:
|
Returns
bool
|
Exceptions
ArgumentException
|
Remarks
Creates new wndFinder and calls wndFinder.IsMatch.
To compare single parameter, use more lightweight code. Examples: if (w.Name.Like("* Notepad"))
, if (w.ClassNameIs("CabinetWClass"))
.
See Also
Overload(top)
Compares window name and other properties like wnd.find does. Can be specified multiple windows.
public int IsMatch(ReadOnlySpan<wndFinder> windows)
Parameters
windows (ReadOnlySpan<wndFinder>) |
Returns
int
1-based index of the match, or 0 if none. |
Examples
var w = wnd.active;
int i = w.IsMatch([new("name1", "class1"), new("name2", of: "program2")]);
print.it(i);
Cache finders to improve performance when IsMatch is called multiple times. Creating all finders each time is expensive.
class C {
static wndFinder[] s_wf1;
void F(wnd w) {
int i = w.IsMatch(s_wf1 ??= [new("name1", "class1"), new("name2", of: "program2")]);
print.it(i);
}
}