AutoHotkey Community

It is currently May 26th, 2012, 12:33 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Show timer on startup?
PostPosted: December 14th, 2008, 12:03 am 
Offline

Joined: November 6th, 2006, 4:18 pm
Posts: 39
Location: Sechelt,BC
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2008, 2:17 am 
Offline

Joined: April 18th, 2007, 9:03 am
Posts: 127
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)...


Report this post
Top
 Profile  
Reply with quote  
PostPosted: December 14th, 2008, 5:22 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2008, 8:36 am 
Offline

Joined: November 6th, 2006, 4:18 pm
Posts: 39
Location: Sechelt,BC
Thanks for help
Redd


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2008, 9:12 am 
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


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Morpheus, Yahoo [Bot] and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group