Jump to content

Can't get Timers to work...


Penny
 Share

Recommended Posts

The timer in this script just doesn't work, I don't get why... I'm frustrated by this!

#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <Timers.au3>

Global $OCR_Debug_BuffCount = 0

Global $Script_Ver = "0.2.16"
Global $Script_DebugMode = True
Global $Script_onerror_Exit = False
Global $Script_Busy = False

Global $GUI_hWnd
Global $Timer_ChatBoxes
Global $Timer_ChatBoxes_Enabled = False

Global $Timer_TradeSanity
Global $Timer_TradeSanity_Enabled = False

Init()

Func Max($n1,$n2)
    If $n1 > $n2 Then
        Return $n1
    EndIf
    
    Return $n2
EndFunc

Func GUIBuild()
    Opt("GUIOnEventMode", 1)

    Dim $ret = GUICreate("test form" & $Script_Ver, 800, 600)

    GUISetOnEvent($GUI_EVENT_CLOSE, "GUIClose")
    GUICtrlCreateLabel("timer testing", 300, 100)
    
    GUISetState(@SW_SHOW)
    
    return $ret
EndFunc

Func GUIClose()
    GUIDelete()
    ConsoleWrite(@CRLF)

    Exit
EndFunc

Func Init()
    $GUI_hWnd = GUIBuild()
    
    MainLoop()
EndFunc

func fruta()
    ConsoleWrite("fruta")
EndFunc

Func MainLoop()
    $al = _Timer_SetTimer($GUI_hWnd,250,"fruta")

    While 1
        Sleep(50)
        ConsoleWrite($GUI_hWnd & @CRLF)
    WEnd
EndFunc

Func ErrorLog($msg)
    _FileWriteLog(@ScriptDir & "\error.log", $msg)
EndFunc
Link to comment
Share on other sites

The timer in this script just doesn't work, I don't get why... I'm frustrated by this!

#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <Timers.au3>

Global $OCR_Debug_BuffCount = 0

Global $Script_Ver = "0.2.16"
Global $Script_DebugMode = True
Global $Script_onerror_Exit = False
Global $Script_Busy = False

Global $GUI_hWnd
Global $Timer_ChatBoxes
Global $Timer_ChatBoxes_Enabled = False

Global $Timer_TradeSanity
Global $Timer_TradeSanity_Enabled = False

Init()

Func Max($n1,$n2)
    If $n1 > $n2 Then
        Return $n1
    EndIf
    
    Return $n2
EndFunc

Func GUIBuild()
    Opt("GUIOnEventMode", 1)

    Dim $ret = GUICreate("test form" & $Script_Ver, 800, 600)

    GUISetOnEvent($GUI_EVENT_CLOSE, "GUIClose")
    GUICtrlCreateLabel("timer testing", 300, 100)
    
    GUISetState(@SW_SHOW)
    
    return $ret
EndFunc

Func GUIClose()
    GUIDelete()
    ConsoleWrite(@CRLF)

    Exit
EndFunc

Func Init()
    $GUI_hWnd = GUIBuild()
    
    MainLoop()
EndFunc

func fruta()
    ConsoleWrite("fruta")
EndFunc

Func MainLoop()
    $al = _Timer_SetTimer($GUI_hWnd,250,"fruta")

    While 1
        Sleep(50)
        ConsoleWrite($GUI_hWnd & @CRLF)
    WEnd
EndFunc

Func ErrorLog($msg)
    _FileWriteLog(@ScriptDir & "\error.log", $msg)
EndFunc

SetTimer Function

http://msdn.microsoft.com/en-us/library/ms644906%28VS.85%29.aspx

C ++ TimerProc Function / Autoit DllCallback $sTimerFunc

http://msdn.microsoft.com/en-us/library/ms644907%28VS.85%29.aspx

#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <Timers.au3>
HotKeySet("{ESC}", "GUIClose")

Global $OCR_Debug_BuffCount = 0

Global $Script_Ver = "0.2.16"
Global $Script_DebugMode = True
Global $Script_onerror_Exit = False
Global $Script_Busy = False

Global $GUI_hWnd
Global $Timer_ChatBoxes
Global $Timer_ChatBoxes_Enabled = False

Global $Timer_TradeSanity
Global $Timer_TradeSanity_Enabled = False , $I = 0

Init()

Func Max($n1,$n2)
    If $n1 > $n2 Then
        Return $n1
    EndIf

    Return $n2
EndFunc

Func GUIBuild()
    Opt("GUIOnEventMode", 1)

    Dim $ret = GUICreate("test form" & $Script_Ver, 200, 200)

    GUISetOnEvent($GUI_EVENT_CLOSE, "GUIClose")
    GUICtrlCreateLabel("timer testing", 300, 100)

    GUISetState(@SW_SHOW)

    return $ret
EndFunc

Func GUIClose()
    GUIDelete()
    ConsoleWrite(@CRLF)

    Exit
EndFunc

Func Init()
    $GUI_hWnd = GUIBuild()

    MainLoop()
EndFunc

func fruta($hWnd, $Msg, $iIDTimer, $dwTime) ;DllCallback $sTimerFunc
    ConsoleWrite("fruta")
    $I += 1
    TrayTip("", $I, 5)


EndFunc

Func MainLoop()
    $al = _Timer_SetTimer($GUI_hWnd,250,"fruta")

    While 1
        Sleep(50)
        ConsoleWrite($GUI_hWnd & @CRLF)

    WEnd
EndFunc

Func ErrorLog($msg)
    _FileWriteLog(@ScriptDir & "\error.log", $msg)
EndFunc

صرح السماء كان هنا

 

Link to comment
Share on other sites

The timer in this script just doesn't work, I don't get why... I'm frustrated by this!

#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <Timers.au3>

Global $OCR_Debug_BuffCount = 0

Global $Script_Ver = "0.2.16"
Global $Script_DebugMode = True
Global $Script_onerror_Exit = False
Global $Script_Busy = False

Global $GUI_hWnd
Global $Timer_ChatBoxes
Global $Timer_ChatBoxes_Enabled = False

Global $Timer_TradeSanity
Global $Timer_TradeSanity_Enabled = False

Init()

Func Max($n1,$n2)
    If $n1 > $n2 Then
        Return $n1
    EndIf
    
    Return $n2
EndFunc

Func GUIBuild()
    Opt("GUIOnEventMode", 1)

    Dim $ret = GUICreate("test form" & $Script_Ver, 800, 600)

    GUISetOnEvent($GUI_EVENT_CLOSE, "GUIClose")
    GUICtrlCreateLabel("timer testing", 300, 100)
    
    GUISetState(@SW_SHOW)
    
    return $ret
EndFunc

Func GUIClose()
    GUIDelete()
    ConsoleWrite(@CRLF)

    Exit
EndFunc

Func Init()
    $GUI_hWnd = GUIBuild()
    
    MainLoop()
EndFunc

func fruta()
    ConsoleWrite("fruta")
EndFunc

Func MainLoop()
    $al = _Timer_SetTimer($GUI_hWnd,250,"fruta")

    While 1
        Sleep(50)
        ConsoleWrite($GUI_hWnd & @CRLF)
    WEnd
EndFunc

Func ErrorLog($msg)
    _FileWriteLog(@ScriptDir & "\error.log", $msg)
EndFunc

I think the help doesn't mention it but the function called by the timer must have 4 parameters as wolf9228 showed. These parameters do not need to be called but they do need to be there, so if I am not going to use them I just have

Func _Timer1($a,$b,$c,$d)

And I just ignore $a, $b $c and $d. If you make that simple change to your script I think it will work.

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 comment
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
 Share

  • Recently Browsing   0 members

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