Friday, August 30, 2013

Get and use MainWindowHandle for a hidden or minimized window

Many thanks for your kind advice. Much appreciated!


After some enjoyable code wrangling, I can now find the MainWindowHandle of almost any window. One case, however, still eludes me.


If the window I want the handle of is minimised when I start my program, the handle is zero. I can find the associated process of the window easily, but even after a process refresh, the handle is still zero.


If I manually (not programmatically) restore the window, I can find the handle. However, that requires an action on the part of the user, which is highly undesirable.


Interestingly, if I manually restore the window and then minimise it again before I try to find the handle, the handle is still zero.


Questions:



  1. How do I find the handle of a window that is minimised and does not produce a handle on process refresh?

  2. How can I programmatically restore a window from the process alone, not using the handle?


Many thanks for your advice.


No comments:

Post a Comment