# Function Reference

# _WinAPI_SetCaretBlinkTime

Sets the caret blink time

#include <WinAPIRes.au3>
_WinAPI_SetCaretBlinkTime ( $iDuration )

## Parameters

$iDuration | The new blink time, in milliseconds. If this parameter is (-1), caret does not blink.

## Return Value

Success: | The previous blink time, in milliseconds.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

## Remarks

The user can set the blink time using the Control Panel. Applications should respect the setting that the user
has chosen. This function should only be used by application that allow the user to set the blink time, such
as a Control Panel applet.

## See Also

Search SetCaretBlinkTime in MSDN Library.

## Example

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WinAPIConv.au3>
    #include <WinAPIGdi.au3>
    #include <WinAPIHObj.au3>
    #include <WinAPIRes.au3>
    #include <WindowsNotifsConstants.au3>

    Global $g_vDuration = Default, $g_hBitmap = _WinAPI_CreateSolidBitmap(0, 0x00AEFF, 10, 14)

    OnAutoItExitRegister('OnAutoItExit')

    Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93)
    Local $idInput = GUICtrlCreateInput('', 20, 20, 360, 20)
    Local $idButton = GUICtrlCreateButton('Exit', 165, 59, 70, 23)
    GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idButton
                ExitLoop
        EndSwitch
    WEnd

    Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
        #forceref $iMsg

        Switch $hWnd
            Case $hForm
                Switch _WinAPI_LoWord($wParam)
                    Case $idInput
                        Switch _WinAPI_HiWord($wParam)
                            Case $EN_KILLFOCUS
                                _WinAPI_HideCaret($lParam)
                                _WinAPI_DestroyCaret()
                                _WinAPI_SetCaretBlinkTime($g_vDuration)
                                $g_vDuration = Default
                            Case $EN_SETFOCUS
                                $g_vDuration = _WinAPI_SetCaretBlinkTime(-1)
                                _WinAPI_CreateCaret($lParam, $g_hBitmap)
                                _WinAPI_ShowCaret($lParam)
                        EndSwitch
                EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
    EndFunc   ;==>WM_COMMAND

    Func OnAutoItExit()
        _WinAPI_DeleteObject($g_hBitmap)
        If Not IsKeyword($g_vDuration) Then
            _WinAPI_SetCaretBlinkTime($g_vDuration)
        EndIf
    EndFunc   ;==>OnAutoItExit