Function Reference


_WinAPI_KillTimer

Destroys the specified timer

#include <WinAPISysWin.au3>
_WinAPI_KillTimer ( $hWnd, $iTimerID )

Parameters

$hWnd Handle to the window associated with the specified timer. This value must be the same as the
$hWnd value passed to the _WinAPI_SetTimer() function that created the timer.
$iTimerID The timer identifier which specifies the timer to be destroyed.

Return Value

Success: True.
Failure: False, call _WinAPI_GetLastError() to get extended error information

Remarks

This function does not remove WM_TIMER messages already posted to the message queue.

Related

_WinAPI_SetTimer

See Also

Search KillTimer in MSDN Library.

Example

Example 1

#include <Misc.au3>
#include <WinAPISysWin.au3>

Opt('TrayAutoPause', 0)

Example()

Func Example()
    Local $hTimerProc = DllCallbackRegister('_TimerProc', 'none', 'hwnd;uint;uint_ptr;dword')

    Local $iTimerID = _WinAPI_SetTimer(0, 0, 1000, DllCallbackGetPtr($hTimerProc))

    ; close script by pressing {ESC}
    Do
        Sleep(100)
    Until _IsPressed('1B')

    _WinAPI_KillTimer(0, $iTimerID)
    DllCallbackFree($hTimerProc)

EndFunc   ;==>Example

Func _TimerProc($hWnd, $iMsg, $iTimerID, $iTime)
    #forceref $hWnd, $iMsg, $iTimerID, $iTime
    Local Static $iCount = 1

    ToolTip("$iCount = " & $iCount, Default, Default, "Press {ESC} to close the script")
    $iCount += 1
EndFunc   ;==>_TimerProc

Example 2 - $pTimerFunc = 0 to use a $WM_TIMER callback

#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <WinAPISysWin.au3>
#include <WindowsNotifsConstants.au3>

Opt('TrayAutoPause', 0)

Example()

Func Example()
    GUIRegisterMsg($WM_TIMER, "WM_TIMER")

    Local $hGUI = GUICreate("_WinAPI_SetTimer[2] - v(" & @AutoItVersion & ")")
    Local $iTimerID = 999
    $iTimerID = _WinAPI_SetTimer($hGUI, $iTimerID, 1000, 0)

    ; close script by pressing {ESC]
    Do
        Sleep(100)
    Until _IsPressed('1B')

    _WinAPI_KillTimer($hGUI, $iTimerID)

    GUIRegisterMsg($WM_TIMER, "")
EndFunc   ;==>Example

Func WM_TIMER($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam, $ilParam
    Local Static $iCount = 1

    ToolTip("$iCount = " & $iCount, Default, Default, "Press {ESC} to close the script")
    $iCount += 1

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_TIMER