Champak Posted May 19, 2006 Share Posted May 19, 2006 This timer is just a portion of the script, but it is the main problem right now. This is suppose to start counting upon pressing "OK", and then stop at the end of the function. But when I hit OK, all that happens is 0:0:0 pops up in the label and I don't see the counting, but the GUI is able to close once the specified sleep time has elapsed. Any help. #include <GUIConstants.au3> GUICreate("test", 283, 280) $timerlabel = GUICtrlCreatelabel("", 10, 30, 150, 18) $ok = GUICtrlCreateButton("Ok", 10, 70, 80, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $ok;Starts mixdown function Function() Case $msg = $GUI_EVENT_CLOSE Exit ExitLoop EndSelect WEnd Func Function() $begin = TimerStart() $processtime = TimerStop($begin)/1000 $processtime2= mod ($processtime, 3600) $hours = ($processtime-$processtime2) / 3600 $processtime = $processtime2 $processtime2= mod ($processtime, 60) $minutes = ($processtime-$processtime2) / 60 $processtime = $processtime2 $seconds= round($processtime) $totalTime = ($hours & ":" & $minutes & ":" & $seconds) GUICtrlSetData($timerlabel, $totalTime) Sleep(2000) EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted May 19, 2006 Developers Share Posted May 19, 2006 Try this to give you an idea how it could be done... #include <GUIConstants.au3> GUICreate("test", 283, 280) $timerlabel = GUICtrlCreateLabel("", 10, 30, 150, 18) $ok = GUICtrlCreateButton("Ok", 10, 70, 80, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $ok;Starts mixdown function $begin = TimerStart() AdlibEnable("Function") Case $msg = $GUI_EVENT_CLOSE Exit ExitLoop EndSelect WEnd Func Function() $processtime = TimerStop($begin) / 1000 $processtime2 = Mod($processtime, 3600) $hours = ($processtime - $processtime2) / 3600 $processtime = $processtime2 $processtime2 = Mod($processtime, 60) $minutes = ($processtime - $processtime2) / 60 $processtime = $processtime2 $seconds = Round($processtime) $totalTime = ($hours & ":" & $minutes & ":" & $seconds) GUICtrlSetData($timerlabel, $totalTime) Sleep(100) EndFunc ;==>Function SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Champak Posted May 19, 2006 Author Share Posted May 19, 2006 I don't understand how it is supposed to end like that. It just keeps counting beyond how long the function is. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 19, 2006 Developers Share Posted May 19, 2006 (edited) I don't understand how it is supposed to end like that. It just keeps counting beyond how long the function is.As said: its to get you started Just put AdlibDisable() at the spot in your script you want to stop the timer... Edited May 19, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Champak Posted May 19, 2006 Author Share Posted May 19, 2006 (edited) You got back before I was able to, I had looked up the adlib and put in the disable part berore you posted....you are quick. But the main reason I'm back with this now, It's not counting when I put the disable in. EDIT: I was looking at if the time is greater than whatever to end...but that wont work because the function does not have a specific time....Out of ideas now. Edited May 19, 2006 by Champak Link to comment Share on other sites More sharing options...
Developers Jos Posted May 19, 2006 Developers Share Posted May 19, 2006 You got back before I was able to, I had looked up the adlib and put in the disable part berore you posted....you are quick. But the main reason I'm back with this now, It's not counting when I put the disable in.Don't know what you really want to do but I assume that when you click on OK the timer starts and you perform some sort of task. Only when that task is completed you do an AdLibDisable().... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Valuater Posted May 19, 2006 Share Posted May 19, 2006 you might run into problems... i just created an adlib for your mem stats i dont think you can run them both... two adlibs 8) Link to comment Share on other sites More sharing options...
Developers Jos Posted May 19, 2006 Developers Share Posted May 19, 2006 you might run into problems...i just created an adlib for your mem statsi dont think you can run them both... two adlibs8)If a timed Function is already used then just add the update for the label to it... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Champak Posted May 19, 2006 Author Share Posted May 19, 2006 (edited) 1/ That is what I'm trying to do, and I did do it like that. I put the adlibdisable right before endfunc. But when that is done, the counter doesn't count...meaning, I can't do anything with the GUI until the time has elapsed(funcend), but the numbers don't move. When I don't put the adlibdisable in, the counter doesn't stop counting until I manually exit. 2/ I think Valuator may be right, because the counter would have to go in a totally different function away from what I want the timer to count for it to be included in the current adlib. 3/ I could have sworn I saw some timers lying around without adlibs in them. I didn't use them because they wouldn't work for me. Why do I need adlib for this? ...So I understand. Edited May 19, 2006 by Champak 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