Add option to find windows containing text instead of having an exact match in findTopWindow

This commit is contained in:
2016-07-03 16:25:32 +01:00
parent 9558c0330f
commit ba460d66e3

View File

@@ -627,10 +627,16 @@ public class Api {
}
public HWND findTopWindow(String text, String className) {
return findTopWindow(text, EXACT, className);
}
public HWND findTopWindow(String text, boolean exact, String className) {
hWndFound = null;
user32.EnumWindows(new WinUser.WNDENUMPROC() {
public boolean callback(HWND hWnd, Pointer lParam) {
if (Api.getWindowText(hWnd).contains(text)) {
String windowText = getWindowText(hWnd);
System.out.println(windowText);
if (exact ? windowText.equals(text) : windowText.contains(text)) {
hWndFound = hWnd;
return false;
} else {