FindWindowA not finding some windows

I'm new to c++ and FindWindowA is working for some processes and not others, for example:FindWindowA(NULL, "Discord"); will work but FindWindowA(NULL, "Fortnite"); won't.

enter image description here

anyone know why? Thanks.

6

2 Answers

FindWindow only finds top level windows. If you are searching for an exact match with the title of the window, then you must take into account hidden characters (space, tab, etc.).

Even if you find the window title, it will only work if that window isn't localized—i.e., if the program that creates that window is localized for a different language, then you must also localize your search string.

A more reliable approach is to search for the class name, since this will typically not be localized: FindWindow("myclass", NULL);

Of course this will still fail if there is a hidden top level window that creates a child window containing the window you are looking for. To get that window, you can call EnumWindows to get the handle of each top level window, and for each top level window found, you then call EnumChildWindows.

Fortnite's window has a space or two

sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
sd.OutputWindow = FindWindow((L"UnrealWindow"), (L"Fortnite "));
sd.SampleDesc.Count = 1;
sd.Windowed = TRUE;

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like