In addition to Solution 1, which will hardly be enough:
You can do the following:
- Get HWND of the desktop window: https://msdn.microsoft.com/en-us/library/windows/desktop/ms633504%28v=vs.85%29.aspx.
- Iterate through all desktop children: https://msdn.microsoft.com/en-us/library/windows/desktop/ms633494%28v=vs.85%29.aspx.
- For each child window, get its bounding rectangle: https://msdn.microsoft.com/en-us/library/windows/desktop/ms633519%28v=vs.85%29.aspx.
- For each child window iterated window, determine if the point is screen coordinates lies inside the rectangle.
- Now, remember that windows can overlap, so the iteration steps described in two previous items may give you more that one window. Choose one of them (https://en.wikipedia.org/wiki/Axiom_of_choice :-)). For this purpose, you may need to consider Z-order of those windows. Instead of iteration explained above, you can take to top window on the desktop and then create a ordered list of all children on Z-order. Please see:
https://msdn.microsoft.com/en-us/library/ms633514%28VS.85%29.aspx,
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633509%28v=vs.85%29.aspx. - Finally, do what Solution 1 suggested: https://msdn.microsoft.com/en-us/library/windows/desktop/ms633520%28v=vs.85%29.aspx.
- PROFIT!
Yes, you need P/Invoke, but all the P/Invoke declarations are already created for you. Just Google on each function name. For example, for first function, it will be
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633504%28v=vs.85%29.aspx.
Remember: if you do all that to uniquely identify some external window or a process, you cannot really rely on window's title. Anyone can give you some application with some stupid window title like "Notepad" or "Explorer". If you explain your ultimate goals, chances are, we can help you better.
—SA