Question

Is there any way to find a window by an incomplete name?

For instance, how would you find a Google Chrome window which can have many title names?
like Stack Overflow - Google Chrome

FindWindow function would work great if the window would always have the same name as a function like the one below would solve it.

HWND chrome = FindWindow(NULL,_T("Stack Overflow - Google Chrome"));
SetForegroundWindow(chrome);

But, what happens if the name changes constantly (like browsers)? How can I find a window by searching for a fixed starting / ending?

I am looking for is something like FindWindow(NULL,_T("something here - Google Chrome").
Is there any way to do it?

Était-ce utile?

La solution

You can use the window classname instead of the window title. For instance, you can find Firefox with

HWND firefox = FindWindow(_T("MozillaWindowClass"), NULL);

You can use any window spy type application like WinSight, WinSpy++, or (the one I used to find the Firefox window class) AutoHotkey's Window Spy utility.

For more info, see the MSDN documentation for FindWindow.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top