The ability to determine the handle (hwnd) of a window or control is central to automation in AutoHotkey and AutoIt. It allows the script writer to “grab” windows by that hwnd (in addition to other methods using PID, title, or class), even if hidden provided certain other criteria are met, such as in this AutoHotkey statement which is self-explanatory:
This also allows “grabbing” windows and controls when multiple instances of the same are present.
I may well be wrong, but in the statement
UIAutomation.GetWindow Control: BringWindowToFront:False WindowInstance=> WindowInstance
I believe the WindowInstance may refer to, or perhaps depend on, the process ID, or the title, or the class, rather than the hwnd.
The ability to save both the hwnd and PID to variables would really come in handy. Perhaps this would be useful, for example, in a new version of “UiAutomation.GetWindow”, which I believe can also be used to get a control as it is.