Funktionreferenz


_WinAPI_KillTimer


Destroys the specified timer

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

Parameter

$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.

Rückgabewert

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

Bemerkungen

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

Verwandte Funktionen

_WinAPI_SetTimer

Siehe auch

Suche nach KillTimer in der MSDN Bibliothek.

Beispiel

Beispiel 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))

    ; Skript durch Drücken von {ESC} schließen

    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, "{ESC} drücken um das Skript zu beenden")
    $g_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