![Laughing :lol:](./images/smilies/icon_lol.gif)
![Uber Geek :ugeek:](./images/smilies/icon_e_ugeek.gif)
Code: Select all
; 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
}