# Function Reference

WinGetHandle

Retrieves the internal handle of a window.

WinGetHandle ( "title" [, "text"] )

Parameters

title | The title of the window to read. See Title special definition.
text | [optional] The text of the window to read.

Return Value

Success: | Returns handle to the window.
Failure: | Returns "" (blank string) and sets @error to 1 if no window matches the criteria.

Remarks

This function is for use with the advanced WinTitleMatchMode options that allow you to use classnames and handles to specify windows rather than "title" and "text".
Once you have obtained the handle you can access the required window even if its title changes.

Related

WinTitleMatchMode (Option)

Example

; Identify the Notepad window that contains the text "this one" and get a handle to it
; Change into the WinTitleMatchMode that supports classnames and handles
AutoItSetOption("WinTitleMatchMode", 4)
; Get the handle of a notepad window that contains "this one"
$handle = WinGetHandle("classname=Notepad", "this one")
If @error Then
MsgBox(4096, "Error", "Could not find the correct window")
Else
; Send some text directly to this window's edit control
ControlSend($handle, "", "Edit1", "AbCdE")
EndIf