GuiFromHwnd

Retrieves the Gui object of a GUI window associated with the specified window handle.

GuiObj := GuiFromHwnd(Hwnd , RecurseParent)

Parameters

Hwnd

Type: Integer

The window handle (HWND) of a GUI window previously created by the script, or if RecurseParent is true, any child window of a GUI window created by the script.

RecurseParent

Type: Boolean

If this parameter is true and Hwnd identifies a child window which is not a GUI, the function searches for and retrieves its closest parent window which is a GUI. Otherwise, the function returns an empty string if Hwnd does not directly identify a GUI window.

Return Value

Type: Object or String (empty)

This function returns the Gui object associated with the specified HWND, or an empty string if there isn't one or the HWND is invalid.

Remarks

For example, the HWND of a GUI window may be passed to an OnMessage function, or can be retrieved via Gui.Hwnd, WinExist or some other method.

Gui(), Gui object, GuiControl object, GuiCtrlFromHwnd, Control Types, ListView, TreeView, Menu object, Control functions, MsgBox, FileSelect, DirSelect

Examples

Retrieves the Gui object by using the HWND of the GUI window just created and reports its title.

MyGui := Gui(, "Title of Window")
MyGui.Add("Text",, "Some text to display.")
MyGui.Show()

MsgBox(GuiFromHwnd(MyGui.Hwnd).Title)