RadAct Posted February 21, 2007 Share Posted February 21, 2007 Correct me if I'm wrong please, but is there a SystemTime() kind of function? You know, from the computer's clock? I did sort of get one working with the hack method, that is, use FileOpen to create a temp file, and then use FileGetTime to get the time and store it in a variable. Creative, but inefficient. Also a variation of the TimerDiff() function where I can compare the difference between a variable that has a previously stored SystemTime() and the current SystemTime(), and be able to return the result in seconds, minutes and seconds or hours minutes seconds etc. I need to keep approx 8 timers going each with different start/end times that I need to monitor, but the TimerInit()/TimerDiff() function is only good for one (as TimerInit() resets each time it is called). Unless someone can come up with an elegant routine to keep track of 8 timers? eg... when each timer hits a predetermined time (in seconds), it needs to perform a particular function. Thanks in advance Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 21, 2007 Moderators Share Posted February 21, 2007 _NowTime(). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 21, 2007 Moderators Share Posted February 21, 2007 Here's a way I just thought of to globaly track your timers.;//Create a Global Timer Track array Global $aTimers[9] ;//Activate timer 1 _TimerTrack($aTimers, 1) Sleep(2000) ;//Activate timer 2 _TimerTrack($aTimers, 2) Sleep(3000) MsgBox(64, 'Info', 'Timer 1 has been ran for: ' & Int(_TimerTrack($aTimers, 1, 0) / 1000) & ' seconds.' & @CR & _ 'Timer 2 has been ran for: ' & Int(_TimerTrack($aTimers, 2, 0) / 1000) & ' seconds.') Func _TimerTrack(ByRef $avArray, $nTimerNum, $nActDiff = 1);nActDiff default = 1 will start timers, 0 will return the difference from when the timer was started If $nActDiff Then $avArray[$nTimerNum] = TimerInit() Else Return TimerDiff($avArray[$nTimerNum]) EndIf Return 1 EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
RadAct Posted February 21, 2007 Author Share Posted February 21, 2007 Can I perform a mathematical calculation on it? eg. $oldtime = _NowTime() $timeout = 10000 $i=0 while $i=0 if (_NowTime() - $oldtime) > $timeout $oldtime = _NowTime() DoStuff() endif enddo Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 21, 2007 Moderators Share Posted February 21, 2007 (edited) Can I perform a mathematical calculation on it? eg. $oldtime = _NowTime() $timeout = 10000 $i=0 while $i=0 if (_NowTime() - $oldtime) > $timeout $oldtime = _NowTime() DoStuff() endif enddoI don't know what you are doing there, might want to look at _NowTime() in the help file to see what the ouput is, I'm sure it's not a number or an integer. If you are just primarily concerned about the timers doing things within certain time frames, then this might be enough for you:expandcollapse popup;//Create a Global Timer Track array Global $aTimers[9], $aTimeAlloted[9] = ['', 10000,3000,2000,1000,10000,12000,15000,20000,10500];//You can set different timer action numbers ;//Set all timers For $iCC = 1 To 8 _TimerTrack($aTimers, $iCC) Next While 1 For $iCC = 1 To 8;//Loop through the 8 timers to check current time If _TimerTrack($aTimers, $iCC, 0) >= $nTimeAlloted[$iCC] Then;//If timer is greater than or equal, then go to function for that timer Switch $iCC;//Timer number you are on Case 1 ;//Function to do for timer 1 if time is reached Case 2 ;//Function to do for timer 2 if time is reached Case 3 ;//Function to do for timer 3 if time is reached Case 4 ;//Function to do for timer 4 if time is reached Case 5 ;//Function to do for timer 5 if time is reached Case 6 ;//Function to do for timer 6 if time is reached Case 7 ;//Function to do for timer 7 if time is reached Case 8 ;//Function to do for timer 8 if time is reached EndSwitch _TimerTrack($aTimers, $iCC);Reset this timer to do it all over again. EndIf Next Sleep(10) WEnd Func _TimerTrack(ByRef $avArray, $nTimerNum, $nActDiff = 1);//nActDiff default = 1 will start timers, 0 will return the difference from when the timer was started If $nActDiff Then $avArray[$nTimerNum] = TimerInit() Else Return TimerDiff($avArray[$nTimerNum]) EndIf Return 1 EndFunc Edited February 21, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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