Add option to find windows containing text instead of having an exact match in findTopWindow
This commit is contained in:
@@ -627,10 +627,16 @@ public class Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HWND findTopWindow(String text, String className) {
|
public HWND findTopWindow(String text, String className) {
|
||||||
|
return findTopWindow(text, EXACT, className);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HWND findTopWindow(String text, boolean exact, String className) {
|
||||||
hWndFound = null;
|
hWndFound = null;
|
||||||
user32.EnumWindows(new WinUser.WNDENUMPROC() {
|
user32.EnumWindows(new WinUser.WNDENUMPROC() {
|
||||||
public boolean callback(HWND hWnd, Pointer lParam) {
|
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;
|
hWndFound = hWnd;
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user