Sign in to follow this  
Followers 0
RagnaroktA

Real-time Timer Question

6 posts in this topic

How would I go about creating a timer that say... counts down from 30, but displays in realtime the amount of time left in the gui?

Example:

This application will install in 30 seconds.

This application will install in 29 seconds.

This application will install in 28 seconds.

(replacing the number in the sentance of course)

Then when count reaches 0, start the application install.


Current Projects:Remote Administration Suite Updated! 12-20-07Remote User State Migration Tool (Plugin) Updated! 12-20-07Batch Print Wizard Updated! 12-20-07Links:AutoIt Beta | AutoIt Wiki

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

1 idea...

#include <GUIConstants.au3>

GUICreate("Timer",320,65,-1,-1,BitOR($WS_POPUP,$WS_DLGFRAME),$WS_EX_TOPMOST)

$label = GUICtrlCreateLabel("30",10,10,300,35,$SS_CENTER)
GUICtrlSetFont(-1,10,700)

$progress = GUICtrlCreateProgress(10,40,300,15)

GUISetState()

$a = TimerInit()

While 1
   If TimerDiff($a) > 30000 Then ExitLoop

   GUICtrlSetData($label,"This application will install in " & _
                  30 - Int(TimerDiff($a) / 1000) & " seconds.")

   GUICtrlSetData($Progress,Int(100*(TimerDiff($a)/30000)))

   Sleep(100)
WEnd

<{POST_SNAPBACK}>

I put your code into the gui I am working in (thanks very much by the way) and it's perfect, except it doesnt allow anything to be clicked (i.e. the Install or Cancel buttons) until it times out. How would I go about making it work with the gui?

What I'm trying to do is write a template gui to start packaging stuff up with. So I want it to have the option to time into installing, or click to install, as well as command line installation that would be silent.

Edited by RagnaroktA

Current Projects:Remote Administration Suite Updated! 12-20-07Remote User State Migration Tool (Plugin) Updated! 12-20-07Batch Print Wizard Updated! 12-20-07Links:AutoIt Beta | AutoIt Wiki

Share this post


Link to post
Share on other sites

you would need to use a GUI msg loop... and incorporate my "while 1" loop into the GUI msg loop.

Lar.

good luck... me busy...

<{POST_SNAPBACK}>

Thanks for your help, I'll give it my best shot and post here if I cant make it happen.

Current Projects:Remote Administration Suite Updated! 12-20-07Remote User State Migration Tool (Plugin) Updated! 12-20-07Batch Print Wizard Updated! 12-20-07Links:AutoIt Beta | AutoIt Wiki

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I put the code inside a msg loop and the buttons work, but the countdown does not. :(

- Edit, nevermind I got it working. Thanks for your help, I'm sure this wont be the last time. Sorry to bother you with such noob work. hah!

Edited by RagnaroktA

Current Projects:Remote Administration Suite Updated! 12-20-07Remote User State Migration Tool (Plugin) Updated! 12-20-07Batch Print Wizard Updated! 12-20-07Links:AutoIt Beta | AutoIt Wiki

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