cSetFocus

This function sets the keyboard focus to the control window specified by the input window handle.

Syntax:

cSetFocus(window-handle)

Parameters:

(i) window-handle Windows handle to control.

Returns:

(i) @TRUE, Keyboard focus set to window; @FALSE, Unable to set keyboard focus.

 

When a window has the keyboard focus, keystrokes are directed to the window. The function will return @FALSE, if it is unable to activate the parent window of the targeted control window. Call the WinActivate function with the name of the control’s parent window before calling cSetFocus, if this problem occurs.

It is best to perform keyboard 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","Filepage setup")
WinWaitExist("Page Setup",5)
; Get a windows handle to the dialog.
openwnd=DllHwnd("Page Setup")
; Get a windows handle to the "Footer" edit control (control id = 31).
editwnd=cWndbyid(openwnd,31)
; Set the keyboard focus to the footer control.
cSetFocus(editwnd)
; Select the existing text and type in new footer text.
SendKey("+{right 20}")
SendKey("Figure &p")
Exit

See Also:

cWndByID, cGetEditText, cSetEditText, WinActivate,DLLhwnd