# Function Reference

# ControlFocus

Sets input focus to a given control on a window.

ControlFocus ( "title", "text", controlID )

## Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.

## Return Value

Success: | 1.
Failure: | 0.

## Related

ControlCommand, ControlGetFocus, ControlSend

## Example

    #include "Extras\HelpFileInternals.au3"

    Example()

    Func Example()
        ; Run Notepad
        Run("notepad.exe")

        Local $hWnd = WinWaitActive("[CLASS:Notepad]", "")

        ; Set input focus to the edit control of Notepad using the handle returned by WinWaitActive.
        ControlFocus($hWnd, "", ControlGetFocus($hWnd))

        ; Wait for 2 seconds.
        Sleep(2000)

        ; Close the Notepad window using the handle returned by WinWaitActive.
        WinClose($hWnd)
    EndFunc   ;==>Example