Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Countdown in MsgBox


  • Please log in to reply
20 replies to this topic
None
  • Members
  • 3199 posts
  • Last active: Nov 05 2015 09:55 PM
  • Joined: 28 Nov 2009

Where is a bug in my code?

The clicks after the Tool tip vanishes are still part of the Settimer thread. (and the return in the settmer breaks the loop)
For this purpose a sub loop is much easier than a Settimer.

But if you realy must use the settimer
Loop 20 { 
MouseClick, left,  253,  598 
Sleep, 1500 
MouseClick, left,  134,  358 
Sleep, 1500 
MouseClick, left,  128,  246 
Sleep, 1500 
MouseClick, left,  200,  420 
Sleep, 1500 
Send, {ESC} 
MouseClick, left,  24,  57 
MouseClick, left,  24,  57 
Sleep, 1500 
MouseClick, left,  155,  192 
Sleep, 1500 
MouseClick, left,  265,  428 
sec:=170
GoSub TimerTip ;use a gosub to make the count down
Sleep % Sec*1000 ;then sleep the same amount of time
Send, {ESC} 
MouseClick, left,  253,  607 
Sleep, 1500 
MouseClick, left,  151,  353 
Sleep, 1500 
MouseClick, left,  144,  252 
Sleep, 1500 
MouseClick, left,  202,  420 
Sleep, 1500 
Send, {ESC} 
}

TimerTip:
SetTimer, RemoveToolTip, 1000 
RemoveToolTip: 
ToolTip, % (Sec--<1) ? "" : FormatSeconds(sec) " seconds remaining." 
If (Sec<0)
 SetTimer, RemoveToolTip, Off
Return 

FormatSeconds(x) 
{ 
Out:=SubStr("0" . Mod(x, 60),-1),x:=Floor(x/60) 
Return x ":" Out 
}


  • Guests
  • Last active:
  • Joined: --
I see now, thank you very much!

AngelicCare
  • Members
  • 18 posts
  • Last active: Jan 08 2011 07:16 PM
  • Joined: 25 Aug 2010

Exactly that's what i wanted to do.

But... i know it works using WHILE, could you explain me the error i am reciving?

Im really breaking my mind at this, why it demands return? Where is a bug in my code?

It's killing me :[


You made a function inside your code... Just inside the loop...

FormatSeconds(x)
{
Out:=SubStr("0" . Mod(x, 60),-1),x:=Floor(x/60)
Return x ":" Out
}


GlxyDs
  • Members
  • 39 posts
  • Last active: Dec 06 2012 10:44 PM
  • Joined: 09 Jun 2011
How could this be done counting down minutes instead of seconds? I want one to count down anywhere from one minute to a half hour in this format:

1:00

Can anyone help?

yrtsh
  • Members
  • 13 posts
  • Last active: Apr 10 2018 09:21 AM
  • Joined: 11 Feb 2015

This one can give a coutdown in sec (in the example 15 sec) displayed in a tooltip next to the cursor

 

Loop 15

{

ToolTip, % 16 - A_Index ; if you just use A_Index it starts at 1 2 3 etc

Sleep 1000

}

Tooltip, 0



yrtsh
  • Members
  • 13 posts
  • Last active: Apr 10 2018 09:21 AM
  • Joined: 11 Feb 2015

little count down (in Tooltip) I found to show the sleep delay (show near the mouse is)

 

 

;;;;;;;;;;;;;;;;;;SHOW COUNT DONWN near the mouse
Loop 20
{
ToolTip, % 21 - A_Index ; if you just use A_Index it starts at 1 2 3 etc
Sleep 1000
}
Tooltip, 0