I'm working on a software for test automation. To get it working it need's to "have a look" on the desktop and all open windows. It needs to know which windows are open and what controls they consist of. So it has to do something similar to what Spy++ is doing (Spy++ from Visual Studio). Does anyone know how Spy ++ get's all the information? Are there any Windows Methods one can call to retrieve information about open windows?
Asked
Active
Viewed 1,055 times
2 Answers
8
You can use EnumWindows to get all top level windows. Within the lpEnumFunc
you can call FindWindowEx to get child windows/controls of each top level window and then any other interesting function that gives you information you need, e.g. GetClassName, GetClassInfo, GetClientRect etc. etc. Take a look here for more

binarybob
- 3,529
- 3
- 23
- 21
4
It's called a windows hook. Checkout the Win32 API SetWindowHookEx.
There are different types of hooks, they reside in a DLL and that DLL function is called by Windows for the type of windows messages of a specific thread or all threads in the same desktop.
Please also see my related answer on Windows hooks here.

Community
- 1
- 1

Brian R. Bondy
- 339,232
- 124
- 596
- 636