Jump to content

Recommended Posts

Posted

#include <Timers.au3>

#include <GUIConstantsEx.au3>

$hWnd = GUICreate ("Hello World!", 200, 100)

GUISetState (@SW_SHOW)

$timer = _Timer_SetTimer ($hWnd, 2000, "myInCorrectCallback")

If $timer = 0 Then MsgBox (0, "", "Timer was not created")

While 1

$msg = GUIGetMsg ()

Switch ($msg)

Case $GUI_EVENT_CLOSE

ExitLoop

EndSwitch

WEnd

Func myInCorrectCallback ()

_Timer_KillTimer ($hWnd, $timer)

MsgBox (0, "", "Time out")

EndFunc

Func myCorrectCallback ($hWnd, $Msg, $iIDTimer, $dwTime)

#forceref $hWnd, $Msg, $iIDTimer, $dwTime

_Timer_KillTimer ($hWnd, $timer)

MsgBox (0, "", "Time out")

EndFunc

----------------------------------------------------------------------

This code leads to AutoIt hangup.

Posted

Welcome to the AutoitForums dmitryunruh,

From the examples in the help file you only need to have one function to _Timer_KillTimer and then call it when ever needed.

$hWnd = GUICreate ("Hello World!", 200, 100)
GUISetState (@SW_SHOW)

$timer = _Timer_SetTimer ($hWnd, 2000, "myCorrectCallback")
If $timer = 0 Then MsgBox (0, "", "Timer was not created")

While 1
    $msg = GUIGetMsg ()
    Switch ($msg)
        Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
WEnd

Func myInCorrectCallback ()
    MsgBox (0, "Debug myInCorrectCallback:", "Time out Incorrect Call Back")
EndFunc ;==>myInCorrectCallback

Func myCorrectCallback ($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime
    _Timer_KillTimer ($hWnd, $timer)
    MsgBox (0, "Debug myCorrectCallback:", "Time out Correct Callback")
    myInCorrectCallback()
EndFunc     ;==>myCorrectCallback

jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...