Jump to content
Sign in to follow this  
Diana (Cda)

How to add this type of countdown w/o new boxes?

Recommended Posts

I searched and searched the archives and came up with a message box countdown that I could make and understand but it is cumbersome. Because it's a series of message boxes that refresh, there is a flicker. I could live with that if it weren't for the dimming and brightening and dimming and brightening each "second" shows.

MsgBox(0, "Counting down ... (10)", "",1)
MsgBox(0, "Counting down ... ( 9)", "",1)
MsgBox(0, "Counting down ... ( 8)", "",1)
MsgBox(0, "Counting down ... ( 7)", "",1)
MsgBox(0, "Counting down ... ( 6)", "",1)
MsgBox(0, "Counting down ... ( 5)", "",1)
MsgBox(0, "Counting down ... ( 4)", "",1)
MsgBox(0, "Counting down ... ( 3)", "",1)
MsgBox(0, "Counting down ... ( 2)", "",1)
MsgBox(0, "Counting down ... ( 1)", "",1)
MsgBox(0, "Done.","You've reached the end.", 2)

I found quite a few messages in the archives but nothing quite does what I need. I looked at ProgressOn which I just found today, too. But mostly solutions seem to revolve around an additional gui, when all I really want to do is put some numbers counting down somewhere on an existing box. Like the above does in the title bar is perfect.

Is there a less cumbersome, more programmatic way to do this?

Thx. :)

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites

Make a GUI with a single Label, then, in your loop, constantly change the label going down

For $i = 1 to 10

$num = 10 - $i

GuiCtrlDetData($Label,"You have "&$num&" seconds left")

Sleep(1000)

Next


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites

Perhaps:

$iTimer = TimerInit()
$iT = 10
While 1
    TrayTip("Countdown", "Seconds remaining: " & $iT, 5)
    If TimerDiff($iTimer) >= 1000 Then
        $iT -= 1
        If $iT < 0 Then ExitLoop
        $iTimer = TimerInit()
    EndIf
    Sleep(100)
WEnd
TrayTip("", "", 5)
MsgBox(16, "Boom!", "Time's up!")oÝ÷ Øô¢ç(ºWZÊ!j÷¢¶;¬¶ê]j×­ëb¶W¨}©òÂ)Ý£"¶¢'­N+ey«­¢+ØÀÌØíA%ôIÕ¸ ÅÕ½Ðí¹½ÑÁ¹áÅÕ½Ðì¤)]¥¹]¥Ð ÅÕ½ÐíU¹Ñ¥Ñ±´9½ÑÁÅÕ½Ðì¤(ÀÌØí¡]¥¸ô]¥¹Ñ!¹± ÅÕ½ÐíU¹Ñ¥Ñ±´9½ÑÁÅÕ½Ðì¤(ÀÌØí¥Q¥µÈôQ¥µÉ%¹¥Ð ¤(ÀÌØí¥PôÄÀ)]¡¥±Ä(%%Q¥µÉ¥ ÀÌØí¥Q¥µÈ¤ÐìôÄÀÀÀQ¡¸($%]¥¹MÑQ¥Ñ± ÀÌØí¡]¥¸°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíM½¹Ìɵ¥¹¥¹èÅÕ½ÐìµÀìÀÌØí¥P¤($$ÀÌØí¥P´ôÄ($%%ÀÌØí¥P±ÐìÀQ¡¸á¥Ñ1½½À($$ÀÌØí¥Q¥µÈôQ¥µÉ%¹¥Ð ¤(%¹%(%M±À ÄÀÀ¤)]¹)
½¹Ñɽ±M¹ ÀÌØí¡]¥¸°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí¥ÐÄÅÕ½Ðì°ÅÕ½Ðí   ==4ÌÌìQ¥µÌäíÌÕÀÌÌìÅÕ½Ðì°Ä¤)M±À ÈÀÀÀ¤)AɽÍÍ
±½Í ÀÌØíA%°Ä¤
Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

or with splash text:

$iTimer = TimerInit()
$iT = 10
While 1
    SplashTextOn("Countdown", "Seconds remaining: " & $iT, 250, 50)
    While TimerDiff($iTimer) <= 1000
        Sleep(10)
    WEnd
    $iT -= 1
    If $iT < 0 Then ExitLoop
    $iTimer = TimerInit()
WEnd
SplashOff()
MsgBox(16, "Boom!", "Time's up!")

Share this post


Link to post
Share on other sites

ARGGHHH, can I get a new brain ... or better yet, an implant that has scripting knowledge in it already!!! <huff>

Okay, I've tried everything I can think of. And though I do really appreciate what I've learned with this exercise, I've also learned that I'm missing something because though I get very interesting results and effects, nothing is what I need. ... how to add a countdown to a messagebox other than my own solution above which I modified from info found here in the forums! <g>

I also realize that I wasn't clear enough. I literally meant to add a countdown to a messagebox but somehow in my mind somewhere somehow thought my own script above would show that. I wasn't thinking. I think my example below illustrates much better what's needed; though a solution that is smoother than this:

MsgBox(0, "(10)", "Launching message box shortly ... ", 1)
MsgBox(0, "(9)", "Launching message box shortly ... ", 1)
MsgBox(0, "(8)", "Launching message box shortly ... ", 1)
MsgBox(0, "(7)", "Launching message box shortly ... ", 1)
MsgBox(0, "(6)", "Launching message box shortly ... ", 1)
MsgBox(0, "(5)", "Launching message box shortly ... ", 1)
MsgBox(0, "(4)", "Launching message box shortly ... ", 1)
MsgBox(0, "(3)", "Launching message box shortly ... ", 1)
MsgBox(0, "(2)", "Launching message box shortly ... ", 1)
MsgBox(0, "(1)", "Launching message box shortly ... ", 1)
Beep(900,250)     ; plays a beep.
MsgBox(0, "Done.", "Hello.", 4)   ; or other script to run, put here.

<g>

p.s., the one with the tray tip didn't work so nothing seemed to be happening. Your 2nd one, PsaltyDS, is the one I managed to get some interesting results with but I'm guessing it's too advanced for me as the result seemed to be applied to every other box but the one I needed no matter where I put it <lol>. That was too funny.

Thanks. :)

Share this post


Link to post
Share on other sites

2 GUI's.... Count down and count up.

Opt ("GUICoordMode"," 2")
$GUI = GUICreate("Timer / down", 200, 50)
GUICtrlCreateLabel ("You have", 10, 10 , 50, 25)
$Rem = GUICtrlCreateLabel("", 0,-1,25, 25, 0x001)
GUICtrlCreateLabel("seconds remaining,", 0, -1, 100)
$Time = 10
GUICtrlSetData($Rem, $Time)
GUISetState()
Do
   Sleep (1000)
   $Time -= 1
   GUICtrlSetData($Rem, $Time)
Until $Time = 0
Sleep(1000);; this is not needed I put it here to allow you to see the display
GUIDelete($GUI)

$GUI = GUICreate("Timer / up", 200, 50)
$Rem = GUICtrlCreateLabel("", 10,10,25, 25, 0x001)
GUICtrlCreateLabel("seconds have passed,", 0, -1, 120)

GUISetState()
$Time = 0
GUICtrlSetData($Rem, $Time)
Do
   Sleep (1000)
   $Time += 1
   GUICtrlSetData($Rem, $Time)
Until $Time = 10
Sleep(1000);; again, this is not needed for the same reason as above
Exit

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Hi, and thanks.

Can I take it to mean, then, that there is _no_ way to put a countdown effect in the title bar of the average message box, to give the effect as my clunky workaround shows above (MsgBox(0, "(1)", "Launching message box shortly ... ", 1)?

Just curious. I don't know GUI syntax very well yet and this code above is still difficult for me to work with. But if it's the only way, I'll have to figure out a way to re-do some of my scripts that are already in place that use the ordinary message box. I just may have to go with my clunky workaround, though. All I need is for an additional bit of text to appear in the title bar that goes from (10), (9), (8) down to (0) before going on to next step but it sure would be nice to just add something to the existing code rather than re-doing it all to a gui. <g>

Thanks! :)

Share this post


Link to post
Share on other sites

I think you are going to have to make your own msgbox instead of the one that the MsgBox() calls.


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

Hi, and thanks.

Can I take it to mean, then, that there is _no_ way to put a countdown effect in the title bar of the average message box, to give the effect as my clunky workaround shows above (MsgBox(0, "(1)", "Launching message box shortly ... ", 1)?

Just curious. I don't know GUI syntax very well yet and this code above is still difficult for me to work with. But if it's the only way, I'll have to figure out a way to re-do some of my scripts that are already in place that use the ordinary message box. I just may have to go with my clunky workaround, though. All I need is for an additional bit of text to appear in the title bar that goes from (10), (9), (8) down to (0) before going on to next step but it sure would be nice to just add something to the existing code rather than re-doing it all to a gui. <g>

Thanks! :)

You will not avoid flicker when using MsgBox()s The reason is that you see the short delay between when one closes and the other opens. Usinf the GUI is your best bet. What you can do (if you want is use WinSetTitle() to display the time in the title bar and use the rest of the GUI as a lable that contains a single message.

$GUI = GUICreate("", 200, 50)
GUICtrlCreateLabel("This is the constant message that I want to be displayed" & @CRLF & "in 2 rows", 5, 5, 190, 40)
GUISetState()
$Time = 10
WinSetTitle($GUI, $Time & " seconds remain")
Do
   Sleep (1000)
   $Time -= 1
   WinSetTitle($GUI, $Time & " seconds remain")
Until $Time = 10
Sleep(1000);; again, this is not needed
Exit

In this case because I only have 1 control in the GUI I didn't use the Opt ("GUICoordMode", 2)

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

I've put several message box ideas together for my own use from scripts on the forum,

maybe this will be of some use to you, look at the scripts this is based on in these posts.

Edit: If what you mean is placing a countdown timer on the message box

of some program other than your script, then look for 'AnyGUI' on the forum.

based on Eltorros script, with ideas from Sunaj and Foxnolds

Eltorro

Move MsgBox, Move a MsgBox where you want it.

Foxnolds

MsgBoxEx UDF

Sunaj

MsgBox behave like a 'standard' child to the main gui

Moveable Messagebox with optional Title and/or Button countdown time label

can make the messagebox a child of parent gui - No separate Taskbar window for message box

messagebox will stay on top of parent gui - Parent Gui locked in place until messagebox is closed

message box will be centered to parent gui - Message box centres to parent gui when launched if gui not centered on screen

option of countdown timer in seconds on Title Bar, and/or any message box button of your choice

uses same command structure as AutoIt messagebox with addition of optional parentgui and button time label

have yet to find a solution to the slight flash of the msgbox as it is moved

Edit: Added default 'space' char to title bar, so if a title is not used the time countdown will still appear

the message box line is drop in replaceable to the native Autoit mesagebox command

just add the 'underscore' to your existing message box code

_MsgBox(1, "", "MsgBox With Countdown Timer" & @CRLF & "MsgBox With Countdown Timer", 20)
MsgBox(1, "", "MsgBox With Countdown Timer" & @CRLF & "MsgBox With Countdown Timer", 20)oÝ÷ Ù«­¢+Ø¥¹±Õ±ÐíÕ¥
½¹ÍѹÑÍà¹ÔÌÐì)=ÁÐ Ìäí5ÕÍѱÉYÉÌÌäì°Ä¤((ìÑ¡Íر¥¹ÌѼѽÀ½ÍÉ¥ÁÐ)=ÁÐ ÅÕ½Ðí]¥¹Q¥Ñ±5Ñ¡5½ÅÕ½Ðì°Ð¤)±½°
½¹ÍÐÀÌØíAA}Q%5I}%ôääää)±½°
½¹ÍÐÀÌØí]5}Q%5HôÁàÀÄÄÌ)±½°ÀÌØíQ%5I9   1ô±Í)±½°ÀÌØí5½Ùô±Í)±½°ÀÌØí5   =a}%9=lÄÅt(ì½Ñ¡Íر¥¹ÌѼѽÀ½ÍÉ¥ÁÐ(((ìÉÁ±ÙÉåÑ¡¥¹±½ÜÑ¡¥Ì±¥¹Ý¥Ñ å½ÕȽ(ì5
Edited by rover

Share this post


Link to post
Share on other sites

Wow, those are incredible! I have no idea how I can translate to my needs yet; all that code makes my eyes dizzy <lol>. But what they do is incredibly neat. I esp. like the countdown in the OK button. That actually is neater than a countdown in the title bar. So will have to study this code so more. I doubt I'll make heads or tails of it any time soon, but I'm slowly, slowly learning so I can only hope that it won't be many weeks or months before I understand better.

Thanks. :)

Share this post


Link to post
Share on other sites

Try using PsaltyDS's window title example, but using an AutoIT generated exe that does nothing more than display a msgbox().

msgbox(0,"","Please wait...")

(built as msg.exe)... then use that exe's PID instead of Notepad. The countdown doesn't happen in the box itself, but the effect is achieved.

Plagiarized below:

$PID = Run("msg.exe")
WinWait("")
$hWin = WinGetHandle("")
$iTimer = TimerInit()
$iT = 10
While 1
    If TimerDiff($iTimer) >= 1000 Then
        WinSetTitle($hWin, "",$iT & "Secs...")
        $iT -= 1
        If $iT < 0 Then ExitLoop
        $iTimer = TimerInit()
    EndIf
    Sleep(100)
WEnd
ControlSend($hWin, "", "Edit1", "BOOM!  Time's up!", 1)
Sleep(2000)
ProcessClose($PID, 1)
Edited by k3v

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  

×
×
  • Create New...