AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Show timer on startup?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
redd



Joined: 06 Nov 2006
Posts: 39
Location: Sechelt,BC

PostPosted: Sat Dec 13, 2008 11:03 pm    Post subject: Show timer on startup? Reply with quote

I would like to show on startup,Then hide or show
Code:
#NoTrayIcon
esc = 1
GOTO START
ESCAPE & F1::GoSub SHOWTIMER


SHOWTIMER:
if esc = 1
{
   Gui, Show, x5 y599 NoActivate
   esc = 0
   RETURN
}
if esc = 0
{
   GUI, Hide
   esc = 1
   RETURN
}

RETURN

START:

SetBatchLines, -1
CustomColor = 000000
Gui +LastFound +AlwaysOnBottom -Caption +ToolWindow
Gui, Color, %CustomColor%
Gui, Font, s20
Gui, Add, Text, vMyText cWhite, XXXXX, YYYYY
WinSet, TransColor, %CustomColor% 250
SetFormat, Float, 02.00
h := m := s := "00"
SetTimer, Update, 1000
Gosub, Update
;Gui, Show, x5 y599 NoActivate
RETURN

Update:
if S = 59
{
   S = 00
   M += 1.0
   GuiControl,, MyText, %H%:%M%:%S%
   RETURN
}
if M = 59
{
   M = 00
   H += 1.0
   GuiControl,, MyText, %H%:%M%:%S%
   RETURN
}
S += 1.0
GuiControl,, MyText, %H%:%M%:%S%
RETURN
Back to top
View user's profile Send private message
lilljimpa



Joined: 18 Apr 2007
Posts: 127

PostPosted: Sun Dec 14, 2008 1:17 am    Post subject: Reply with quote

here is one way of doing it

Code:
#NoTrayIcon

SetTimer, Update, 1000

SetBatchLines, -1
CustomColor = 000000
Gui +LastFound +AlwaysOnBottom -Caption +ToolWindow
Gui, Color, %CustomColor%
Gui, Font, s20
Gui, Add, Text, vMyText cblue, XXXXX, YYYYY
Gui, Show, x5 y599 NoActivate
WinSet, TransColor, %CustomColor% 250
SetFormat, Float, 02.00
h := m := s := "00"
RETURN

Update:
if S = 59
{
   S = 00
   M += 1.0
   GuiControl,, MyText, %H%:%M%:%S%
   RETURN
}
if M = 59
{
   M = 00
   H += 1.0
   GuiControl,, MyText, %H%:%M%:%S%
   RETURN
}
S += 1.0
GuiControl,, MyText, %H%:%M%:%S%
RETURN


ESCAPE & F1::
if hidden = true
{
gui 1:show
hidden = false
}

else
{
gui 1:hide
hidden = true
}

_________________
you'll have to excuse me...I'm from Sweden, so my English is not that good...(but now it's better cuz JSLover/Guest is helping me)...
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Guest






PostPosted: Sun Dec 14, 2008 4:22 am    Post subject: Re: Show timer on startup? Reply with quote

redd wrote:
I would like to show on startup,Then hide or show
Code:
#NoTrayIcon
esc = 1
; GOTO START  ; needs to be GoSub
GoSub, START  ;  like this
GoSub, SHOWTIMER ; add this to show on start up

ESCAPE & F1::GoSub SHOWTIMER

SHOWTIMER:
; ...

These two changes make it work the way you want.
Back to top
redd



Joined: 06 Nov 2006
Posts: 39
Location: Sechelt,BC

PostPosted: Sun Dec 14, 2008 7:36 am    Post subject: Reply with quote

Thanks for help
Redd
Back to top
View user's profile Send private message
me again
Guest





PostPosted: Sun Dec 14, 2008 8:12 am    Post subject: Reply with quote

Here is a revision of your Update subroutine, it uses standard AHK commands to calculate and format the elapsed time. (also added a couple of useful hotkeys. I tested this code and it works.
Code:
#NoTrayIcon
esc = 1
; GOTO START  ; needs to be GoSub
GoSub, START  ;  like this
GoSub, SHOWTIMER ; add this to show on start up

ESCAPE & F1::GoSub SHOWTIMER
#b::tStart := A_Now  ; added hotkey (win+b) to reset elapsed timer to 0
#x::ExitApp   ; added hotkey (win+x) to exit script

SHOWTIMER:
if esc = 1
{
   Gui, Show, x5 y599 NoActivate
   esc = 0
   RETURN
}
if esc = 0
{
   GUI, Hide
   esc = 1
   RETURN
}

RETURN

START:

; SetBatchLines, -1   ; this is not useful for anything in this script
CustomColor = 000000
Gui +LastFound +AlwaysOnBottom -Caption +ToolWindow
Gui, Color, %CustomColor%
Gui, Font, s20
Gui, Add, Text, vMyText cWhite, XXXXX, YYYYY
WinSet, TransColor, %CustomColor% 250
tStart := A_Now      ; save script start time for future elapsed time calculation
SetTimer, Update, 200  ; makes for smoother display update
Gosub, Update
;Gui, Show, x5 y599 NoActivate
RETURN

Update:
if !(tNow = A_Now) {   ; if time has not changes, return
  tTemp := tNow := A_Now
  EnvSub, tTemp, tStart, seconds  ; calculate # of seconds since script start
  tdummy = 20000101
  EnvAdd, tdummy, tTemp, seconds  ; add # of seconds to dummy date/time
  FormatTime, elapsed, %tdummy%, HH:mm:ss  ; only show hour, minutes, seconds
  GuiControl,, MyText, %elapsed%
}
RETURN
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group