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.

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

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.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest