Sign in to follow this  
Followers 0
Champak

Timer Not Working

9 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I don't understand how it is supposed to end like that. It just keeps counting beyond how long the function is.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Champak

Share this post


Link to post
Share on other sites

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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)

If a timed Function is already used then just add the update for the label to it...

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by Champak

Share this post


Link to post
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
Sign in to follow this  
Followers 0