Jump to content

Why does my timer freeze?


Recommended Posts

I am writing a simple script that will use a timer. I wrote most of the script, but when I add the timer, it freezes the script to the point where I have to End Task on it. Trying to figure out what is causing the freeze, I cut the script down to it's most basic pieces, but it is still freezing.

Can someone tell me why?

Here is the most basic code I have, which still freezes on my PC:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <timers.au3>

$frmAutoClicker = GUICreate("AutoClicker", 105, 65, 192, 114)
GUISetState(@SW_SHOW)

Func DoNothing()
EndFunc

$tmrAutoCLick = _Timer_SetTimer($frmAutoClicker,2000,"DoNothing")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Link to post
Share on other sites

It's a failing of the help file because it should tell you that the function must have 4 parameters even if you don't use them. so

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <timers.au3>

$frmAutoClicker = GUICreate("AutoClicker", 105, 65, 192, 114)
GUISetState(@SW_SHOW)

Func DoNothing($a,$b,$c,$d)
#forceref $a, $b, $c, $d; set these variables as 'referenced' so the compiler doesn't complain they haven't been used.
EndFunc

$tmrAutoCLick = _Timer_SetTimer($frmAutoClicker,2000,"DoNothing")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Edit: Added the #forceref line

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to post
Share on other sites

It's a failing of the help file because it should tell you that the function must have 4 parameters even if you don't use them.

Ah, I see it now. In the help page for _Timer_SetTimer is the example, which runs just fine of course, with 2 timer-called functions, declared thusly:

Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime

Func _UpdateProgressBar($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime

These functions have the 4 parameters, but as you stated, the help page fails to state that timer-called functions MUST have these parameters.

OK, problem solved, thank you very much for your help.

Link to post
Share on other sites

It's a failing of the help file because it should tell you that the function must have 4 parameters even if you don't use them.

Ah, I see it now. In the help page for _Timer_SetTimer is the example, which runs just fine of course, with 2 timer-called functions, declared thusly:

Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime

Func _UpdateProgressBar($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime

These functions have the 4 parameters, but as you stated, the help page fails to state that timer-called functions MUST have these parameters.

OK, problem solved, thank you very much for your help.

Link to post
Share on other sites

It's a failing of the help file because it should tell you that the function must have 4 parameters even if you don't use them.

Ah, I see it now. In the help page for _Timer_SetTimer is the example, which runs just fine of course, with 2 timer-called functions, declared thusly:

Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime

Func _UpdateProgressBar($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime

These functions have the 4 parameters, but as you stated, the help page fails to state that timer-called functions MUST have these parameters.

OK, problem solved, thank you very much for your help.

Link to post
Share on other sites

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