c++winapispy++

Spy++ Win32 API Getting Window instance from Spy++ Information


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. enter image description here


Solution

  • 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.