Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Countdown timer app


  • Please log in to reply
18 replies to this topic
AllanM
  • Members
  • 8 posts
  • Last active: Mar 11 2019 04:26 PM
  • Joined: 31 Jul 2013

This script does nothing at all!

It only shows a box with 6 red zeros, "time elapsed 0%" and nothing else. The script has no explanation inside.

What do i have to modify to use the timer?

 

It actually does a lot, if you bother to look at the source, or just try a little simple exploration. Go to your system tray, right click the icon and a little menu will pop up with options End Time, Period, Message and Exit. 

 

Not at all hard to figure out. And if you look at a subsequent post you will see a few more lines to add to it to get a menu displayed in the timer window as well.



Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

This countdown counter counts down or backward as designed (in this case, starts from 3 minutes and counts down to 0). what i would like to do is to reverse the process so that it counts up or forward from 0 (NOT from %A_Now%) to 3 minutes. i spent some time and couldn't make the necessary changes to the existing code, but i have a feeling that only a slight, surgical change is required somewhere in this working code:

; http://www.autohotkey.com/community/viewtopic.php?f=2&t=62008

#SingleInstance FORCE

XI = %A_ScreenWidth%
YI = %A_ScreenHeight%

XPos := XI/2
YPOs := YI/2
Message = "Log download complete"

XInput := XI-250
YInput := YI-150
; On-screen display (OSD)

CustomColor = 99AA55 ; C0C0C0 ; Can be any RGB color (it will be made transparent below):
Menu ,Tray, NoStandard
;Menu ,Tray, Add
Menu,Tray, Add,
Menu,Tray, Add, Exit, GuiClose
Gui +LastFound +AlwaysOnTop +Caption +ToolWindow +OwnDialogs
Gui, Color, %CustomColor%
Gui, Font, s10
;Gui Add , Text , x0 y10 w130 h15 vpercent +Center, Time Elapsed %perc%`%
Gui Add , Progress , x5 y30 w120 h10 cRed vmyprogress
Gui, Font, s16
Gui, Add, Text, x5 w120 vMyTime cRed +Center, -00:00:00
WinSet, TransColor, %CustomColor% 175 ; Make all pixels of this color transparent and make the text itself translucent (150):
/*
SetTimer, UpdateOSD, 200 ; Causes a subroutine to be launched automatically and repeatedly at a specified time interval.
Gui, Show, x%XPos% y%YPos% w130 NoActivate, Script_Running ; NoActivate avoids deactivating the currently active window.
Return ; // End of Auto-Execute Section
*/

Loop, 1 ; 3
{
   ; MsgBox, Iteration number is %A_Index%. ; A_Index will be 1, 2, then 3
   Sleep, 100 ; 1000

   SetTimer, UpdateOSD, 200 ; Causes a subroutine to be launched automatically and repeatedly at a specified time interval.
   Gui, Show, x%XPos% y%YPos% w130 NoActivate, Script_Running ; NoActivate avoids deactivating the currently active window.

   Gui +LastFound +AlwaysOnTop +Caption +ToolWindow +OwnDialogs
   WinGetPos ,XPos ,YPos,,,Progress,
   ;Period = 00000025 ; Specified a known static Period (25 seconds)
   ;Period = 00000100 ; Specified a known static Period (1 minute) <<<<<<<<<<<<< 1 min
   Period = 00000300 ; Specified a known static Period (3 minutes) <<<<<<<<<<<<< 3 min
   StringMid ,PeriodD, Period,1, 2
   StringMid ,PeriodH, Period,3, 2
   StringMid ,Periodm, Period,5, 2
   StringMid ,Periods, Period,7, 2
   Periodsec := (PeriodD*86400)+(PeriodH*3600)+(Periodm*60)+Periods
   StartTime = %A_Now%
   ;EndTime = %A_Now%
   ;EndTime = 20121021181050
   EnvAdd EndTime, Periodsec, seconds
   EnvSub StartTime, EndTime, seconds
   StartTime := Abs(StartTime)

   perc := 0 ; Resets percentage to 0, otherwise this loop never sees the counter reset
   Loop
   {
       if perc = 100
           break ; Terminate the loop
       else
           continue ; Skip the below and start a new iteration
   }
    Gui, Cancel
    ExitApp
}

UpdateOSD:
mysec := EndTime
EnvSub, mysec, %A_Now%, seconds
GuiControl,, MyTime, % FormatSeconds( mysec )
perc := ((StartTime-mysec)/StartTime)*100
;MsgBox %StartTime%
perc := Floor(perc)
;MsgBox %perc%
GuiControl ,,myprogress,%perc%
;GuiControl ,,percent, Time Elapsed %perc%`%
If (perc=100){
    SetTimer, UpdateOSD, Off
    GuiControl ,,percent, Done %perc% `%
    Gui, Cancel
    }
Return

GuiClose: ; writes the settings into a ini file to get the position and continue count from last point (for long periods, endtimes where you had to shutdown the computer)
ExitApp

FormatSeconds(NumberOfSeconds) ; Convert the specified number of seconds to hh:mm:ss format
{
    time = 19990101 ; *Midnight* of an arbitrary date.
    time += %NumberOfSeconds%, seconds
    FormatTime, mmss, %time%, mm:ss
    hours := NumberOfSeconds // 3600 ; This method is used to support more than 24 hours worth of sections
    hours := hours < 10 ? "0" . hours : hours
    return hours ":" mmss
}


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

2 new lines added and 1 existing line modified and that did the trick! :D



pecsabi
  • Members
  • 4 posts
  • Last active: Jun 14 2015 02:20 PM
  • Joined: 08 Aug 2014

Hi guys,

I added a countdown timer feature to the desktop clock originally published here: http://www.autohotke...-onscreen-time/

I've just shared my version on the same site: http://www.autohotke...-time/?p=662909