Jump to content

Timer with options


Recommended Posts

Hello, I've tried to create a timer that has options what to do after the time reaches zero, like _timer($seconds, $option), _timer(2000, exit)

So if i have an option like "update"(_timer(1000, update)) then the timer would look for "update" in the Case part.

Can someone help me with this? When i tried the script just eaten up the RAM

Here's an example:

_TIMER($time, $option)
;timer part
;This is the part i need help with
Case $option = "update"
    _update()
    
Case $option = "exit"
    ExitLoop
Edited by Chris86
Link to comment
Share on other sites

help anyone :S?

Not sure if I understand what you want to do but maybe this would help.

#include <timers.au3>


TimerFunc(2000,"sayhello")
TimerFunc(9000,"sayBye")
Global $hWnd = 0;use the handle to your gui if you have one

while 1
    
    sleep(90)
WEnd


Func TimerFunc($t,$sFunc)
_timer_SetTimer($hWnd,$t,$sFunc)
EndFunc

FUnc sayhello($hWnd, $Msg, $iIDTimer, $dwTime)
ConsoleWrite($iIDTimer & @CRLF)
_Timer_KillTimer($hWnd,$iIDTimer)
msgbox(4,"hello","ok?",3)
EndFunc

Func sayBye($hWnd, $Msg, $iIDTimer, $dwTime)
    ConsoleWrite($iIDTimer & @CRLF)
    _Timer_KillTimer($hWnd,$iIDTimer)
    msgbox(0,"Bye", "see you",2)
    exit
EndFunc

EDIT: Corrected error in variable name $hWnd and added Global declaration for it.

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