Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FindWindow with partial window title (Windows, C)

Is there any API similar to FindWindow() but that searches the windows by partial title? The reason is that I need to the handle to a window that has a fix part on the title but the other part changes constantly. So for example the window title could be:

DataBase read: XYDB

or

DataBase read: WZDB

in the examples the fix part is "DataBase read:"

Code appreciated. Thanks

like image 301
wonderer Avatar asked Dec 19 '25 00:12

wonderer


1 Answers

An example using EnumWindows:

BOOL CALLBACK WorkerProc(HWND hwnd, LPARAM lParam) {
    static TCHAR buffer[50];

    GetWindowText(hwnd, buffer, 50);
    if(_tcsstr(buffer, "window name goes here")) {
        // do something with hwnd here
        return FALSE;
    }

    return TRUE;
}

And then call it like this:

EnumWindows(WorkerProc, NULL);
like image 66
arul Avatar answered Dec 21 '25 14:12

arul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!