cGetFocus

Retrieves handle of the window with keyboard focus

Syntax:

cGetFocus()

Parameters:

None

Returns:

(i) window-handle Handle to window with the keyboard focus.

 

This function returns the window handle of the window with keyboard focus. When a window has the keyboard focus, keystrokes are directed to the window. The function will return 0, if no window had the keyboard focus. This can occur when the focus is in transition from one window to another. In an effort to avoid returning a 0, the function attempts to identify the focus window several times.

It is best to perform keyboard related tasks immediately after calling this function. This is because keyboard focus is a temporary window state and system activity can quickly switch it to another window.

 

Example:

AddExtender("wwctl44i.dll",0,"wwctl64i.dll")

; Start Notepad Run("notepad.exe","") ; Activate the Print Setup dialog. SendMenusTo("~Notepad","File Open") WinWaitExist("Open",5) ; Get the window with the focus. hFocus = cGetFocus() If hFocus    sAttributes = ""    ; Get the focus windows information.    sTitle = cWndinfo(hFocus, 0)    sAttributes = ItemInsert("Title %sTitle%", -1, sAttributes, @TAB)    nId = cWndinfo(hFocus, 1)    sAttributes = ItemInsert("ID %nId%", -1, sAttributes, @TAB)    sClass = cWndinfo(hFocus, 2)    sAttributes = ItemInsert("Class %sClass%", -1, sAttributes, @TAB) Else    sAttributes = "No windows has the input focus" EndIf ; Display the results sAttributes = StrReplace(sAttributes, @TAB, @CRLF) Message("Focus Window's Attributes", sAttributes) Exit

See Also:

cSetFocus