Home > Language Reference > Windows Management Functions > GetFocusWindowHandle

GetFocusWindowHandle

The GetFocusWindowHandle function returns the handle of the foreground window.

Usage

Used to acquire dynamically the focused window handle. This window handle can then be used in a UseWindowHandle statement.  

Syntax

handle=GetFocusWindowHandle()

Parameters

None.

Return value

handle, integer, handle of the foreground window.

See also

GetTopWindowHandle
GetWindowHandle
GetWindowName$
UseWindowHandle

Example

Shell("notepad.exe")
'wait 1 second for notepad window to be loaded
pause 1
'Retrieve the handle of the focused window
a=GetFocusWindowhandle()
'Display the handle
msgbox(a)
'This handle can be used in UseWindowHandle function and then SendKeys sends the specifed keys to that handled window.
UseWindowHandle(a)
SendKeys("Hello")