How do I find a window by partial title.. or if the title contains a certain word..

I was thinking GetWindowText but that requires that I have the handle already..
I was going to enum windows I think that I can search for a window title containing the string.. if it finds the string, compare it to mine and if it is the same then get the handle.

Or is there a better way to find the window for sure?
By Process? By FileName? *gah* brain overload.

If you only know part of the string then use enum windows, then in the callback function call GetWindowText.

Did this:

BOOL CALLBACK WorkerProc(HWND hwnd, LPARAM lParam){
    GetWindowText(hwnd, buffer, 50);
    if(buffer, L"FireFox") {
        // do something with hwnd here
		::SendMessage(hwnd, WM_KEYDOWN, VK_F12,0);
        return FALSE;

    return TRUE;

Called it like so:

EnumWindows(WorkerProc, NULL);

But it didnt compile :S

>> if(buffer, L"FireFox") {
It didn't compile because of the above line. How is buffer declared? Where is buffer declared? And that if statement is just constructed wrong.

You need something like this: if( strstr(buffer,"FireFox") != NULL) or if you are compiling for UNICODE then use _tcsstr (it is for Microsoft compilers) instead of strstr()