FindTopWindow

Find a top level window matching the selection criteria.

Control FindTopWindow(string wantedText);

Control FindTopWindow(string wantedText, int maxWait);

Control FindTopWindow(string wantedText, TextMatch textMatch);

Control FindTopWindow(string wantedText, TextMatch textMatch, int maxWait);

Control FindTopWindow(string wantedText, string wantedClass);

Control FindTopWindow(string wantedText, string wantedClass, int maxWait);

Control FindTopWindow(string wantedText, string wantedClass, TextMatch textMatch);

Control FindTopWindow(string wantedText, string wantedClass, TextMatch textMatch, int maxWait);

Control FindTopWindow(Predicate<Control> selectionFunction);

Control FindTopWindow(Predicate<Control> selectionFunction, int maxWait);

Parameters

wantedText: The text caption of the Control.  The default match criteria is contains, case insensitive. This value can be none or an empty string "" if you are only matching on wantedClass.

maxWait: The maximum time in milliseconds to wait for the window to be created. The default value is 120,000 milliseconds (2 minutes).

textMatch: Options are TextMatch.Contains (default), TextMatch.Exact, TextMatch.StartsWith, TextMatch.EndsWith, TextMatch.MatchCase See TextMatch.

wantedClass: The window class name.

selectionFunction: A reference to a user supplied selection function. See SelectionFunction.

Return Value

A Control object that can be used to access the found window.

Remarks

This method is one of the first called to identify a required top level window or dialog. The window can be matched on caption, a caption and a class name, or a custom selection function.

If a matching window is not found, a TimeoutException is thrown.  You can catch this exception as shown below.

Example

Control notepadWindow = FindTopWindow("Untitled - Notepad");

Control word_w = FindTopWindow("Microsoft Word", TextMatch.EndsWith);

Control explorer_w = FindTopWindow(none, "ExploreWClass", 10000); // explorer window, wait for 10 seconds

Control explorer_w = FindTopWindow(myFunction, 10000); // call a user supplied method bool myFunction

 

Control window;

try

{

window = FindTopWindow("myWindow", 20000); // wait for 20 seconds

WriteMessage("myWindow Openl");

}

catch (Facilita.Exception.TimeoutException e)

{

Error(@"Failed to find top windowl");

}

Related:

 

This topic was last updated on June 21, 2019, at 02:49:50 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2019 Eggplant