DonationCoder.com Software > Post New Requests Here
simple timer
belkira:
Ok So I created another one with the timer showing. It shows in the form of a small tooltip box in the upper right corner of the monitor.
See if you like it, the tooltip can be moved around by playing with its coords.
--- ---;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <[email protected]>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#persistent
#singleinstance off
CoordMode, ToolTip, Screen
tt = %1%
time := Convert_Milliseconds(tt)
Sec := (tt * 60)
SetTimer, Message, %time%
countdown(Sec)
return
Message:
SetTimer, Message, Off
msgbox Done!
ExitApp
Convert_MilliSeconds(time,MS = 1000,M = 60)
{
return MS*M*time
}
countdown(p_count="") {
countdown_time:=p_count
countdown_date=16010101
countdown_date+=%countdown_time%, s
Loop {
If (countdown_date >= 16010101010000){
FormatTime, mmss, %countdown_date%, hh:mm:ss
}else{
FormatTime, mmss, %countdown_date%, mm:ss
}
;msgbox %countdown_date%`n%hhmmss%
;//SB_SetText(mmss, 2)
Tooltip, %mmss%, 2000,20
Sleep, 1000
countdown_date+=-1, s
;//IfLess, countdown_date, 16010101, break
if (A_Index>countdown_time) {
break
}
}
}
dbarton:
I like that countdown you have!
Which line ha sthe coordinates? I'd like lower left...
This is what I was doing:
timer=120
Gui, Add, Button, w135 Default Vcounter END, STARTED: %timer% mins
Gui, Show, x1 y1,
SetTimer, COUNTDOWN, 60000 ; 60,000 for one minute steps
return
COUNTDOWN:
timer-=1
GuiControl,, counter, TIME LEFT: %timer% min
If timer=0
Goto, END
Return
belkira:
The Coords are on this line:
--- --- Tooltip, %mmss%, 2000,20
The first number, 2000 in this case is the left right and the second number, 20, is the up down.
You can also add this line right below that line to get a "tray tip" when you hover the mouse over the icon in the tray:
--- ---Menu,Tray,Tip,Time Remaining: %mmss%
Glad you liked it!
dbarton:
I guess my next question is:
Is there a way to cancel the timer once running?
Seems like there's no X so no place for a mouse to do the cancelling.
Can't grab a key, as best I can tell..
Maybe I could mouseover the timer to get a cancel button?
Not really sure how to handle that..
Here's what i have, using your code:
#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#persistent
CoordMode, ToolTip, Screen
tt = %1%
;tt = 120
time := Convert_Milliseconds(tt)
Sec := (tt * 60)
SetTimer, nMessage, %time%
countdown(Sec)
return
nMessage:
SetTimer, nMessage, Off
SoundGet, volumeBackup
SoundGet, master_mute, , mute
if master_mute = on
SoundSet, +1, , mute
SoundSet, +100 ;Set it to the highest volume
Gui, +MinimizeBox
GUi, -sysmenu
gui, +toolwindow
Gui, Add, Button, w130, DONE- hit 'O' for OK
Gui, Show, x1 y1, dTIME 1.1
SoundBeep, 500, 100
Sleep 100
SoundBeep, 1500, 100
Sleep 100
SoundBeep, 1500, 100
Sleep 100
SoundBeep, 1500, 100
Sleep 100
SoundBeep, 1500, 100
Sleep 100
SoundBeep, 1500, 100
Sleep 100
SoundBeep, 1500, 100
If master_mute = on ; Restore the volume
SoundSet, +1, , mute
soundset, %volumeBackup%
KeyWait, o, D
Tooltip ,, 2, 980
Gui Destroy
exitapp
Convert_MilliSeconds(time,MS = 1000,M = 60)
{
return MS*M*time
}
countdown(p_count="") {
countdown_time:=p_count
countdown_date=16010101
countdown_date+=%countdown_time%, s
Loop {
If (countdown_date >= 16010101010000){
FormatTime, mmss, %countdown_date%, hh:mm:ss
}else{
FormatTime, mmss, %countdown_date%, mm:ss
}
;msgbox %countdown_date%`n%hhmmss%
;//SB_SetText(mmss, 2)
Tooltip, %mmss%, 2,980
Sleep, 1000
countdown_date+=-1, s
;//IfLess, countdown_date, 16010101, break
if (A_Index>countdown_time) {
break
}
}
}
belkira:
right now the only way to cancel once running is to right click on the tray icon and exit. You could put a hotkey in to kill it.
#e::exitapp or something like that....
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version