Uten Posted April 22, 2007 Share Posted April 22, 2007 Just a simple sample on a question asked rather often. There are probably better samples in the forum. I have entered this for later reference. expandcollapse popup;TimerLib.au3 ; #region - Timer Global $TimerStorage[10][3] Func TimerAdd($funcname, $ms) dbg("TimerAdd($funcname:=" & $funcname & ", $ms:=" & $ms) $ret = $TimerStorage[0][0] + 1 $TimerStorage[$ret][0] = $funcname $TimerStorage[$ret][1] = $ms $TimerStorage[$ret][2] = 0 $TimerStorage[0][0] = $ret Return $ret EndFunc Func TimerRemove($id) $TimerStorage[$id][0] = "" $TimerStorage[$id][1] = "" $TimerStorage[$id][2] = 0 EndFunc Func TimerCheck() ;;;dbg("TimerCheck::$TimerGo:=" & $TimerGo) For $i = 1 to $TimerStorage[0][0] If $TimerStorage[$i][0] <> "" Then If $TimerStorage[$i][2] = 0 Then $TimerStorage[$i][2] = TimerInit() ElseIf TimerDiff($TimerStorage[$i][2]) >= $TimerStorage[$i][1] Then ;;;dbg("Calling: " & $TimerStorage[$i][0]) Call($TimerStorage[$i][0]) $TimerStorage[$i][2] = TimerInit() EndIf EndIf Next EndFunc #endregion - Timer Func Main() HotKeySet("{ESC}", "Terminate") TimerAdd("A", 1000) TimerAdd("B", 300) TimerAdd("C", 33) AdLibEnable("TimerCheck", 25) While True sleep(10) WEnd Exit EndFunc Func Terminate() Exit EndFunc Func A() dbg("A Called") EndFunc Func B() dbg("B Called") EndFunc Func C() dbg("C Called") EndFunc Func dbg($msg, $line=@ScriptLineNumber, $err=@error, $ext=@extended) ConsoleWrite("(" & $line & ") := (" & $err & ")(" & $ext & ") " & $msg & @CRLF) EndFunc ; ==================== Main() Exit Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
jerome Posted April 24, 2007 Share Posted April 24, 2007 Hi, This example seems partially inspired from my TimerLib (same name, same function names, etc...) but this one doesn't works because this is more complicated than it seems. Please avoid sucking up other people's scripts with no added value (subtracted value I should say)... Thanks in advance Jérôme Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now