I am using Spy++ to find windows, I am doing this as a test and realise the Handles change fequently. However, here is the information I get from Spy++. Can I use these handles to grab that window in C++
Here's how I get it from the name.
HWND main_window_handle = FindWindowA(NULL, WINDOW_NAME);
How can I get it using either the Window Handle or Instance Handle.
The window handle is the HWND
and their values are not stable, it will probably change every time you run the program.
The instance handle (HINSTANCE
) is also not stable and has little to do with finding a specific window in another application, it is the load address of the module (.exe or .dll) that created the window.
To find a window you will generally call FindWindow
with a specific class name. If the class name of the window you are looking for is not really unique then you should probably use EnumWindows
and try to look for other specific attributes and/or child windows to identify the top level window you are looking for.
It is also possible (and often the best approach) to use UI Automation to find and manipulate windows in 3rd-party applications.