|
dbarton
|
 |
« on: September 12, 2008, 02:39:18 PM » |
|
I'm looking for a timer that starts with a variable that says how long to time for..
In other words.. I could have a link to it saying MYTIMER.EXE 120, and it would time for 120 mins then make a noise. I might have another icon set up for 'MYTIMER 60' to time for one hour.
All the timers I have found requires you to start them up, then set the time you desire.
The application is to take medication 120 mins after I eat.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
Paul Keith
|
 |
« Reply #2 on: September 12, 2008, 04:13:15 PM » |
|
I forgot, I think the default timer panel for Gnome (Linux) also does this.
|
|
|
|
|
Logged
|
<reserve space for the day DC can auto-generate your signature from your personal PopUp Wisdom quotes>
|
|
|
|
|
belkira
|
 |
« Reply #3 on: September 12, 2008, 04:55:23 PM » |
|
using AutoHotKey you could do something like this: [ copy or print] #persistent #singleinstance off %1% := 60 * (%1% * 1000) SetTimer, Message, %1% return Message: SetTimer, Message, Off msgbox Done! ExitApp Then just create shortcuts as needed with the appropriate time.
|
|
|
|
|
Logged
|
|
|
|
|
dbarton
|
 |
« Reply #4 on: September 12, 2008, 05:58:56 PM » |
|
This AHK scriot looks good, but doesn't quite work 100% for me. The time calcs may be off.. I feel silly, but I'm having a bit of trouble understanding some of it. Any chance of breaking it down?
Any way to add a countdown by minute? Looks like settime function may not allow that.
thanks!!
|
|
|
|
« Last Edit: September 12, 2008, 06:33:15 PM by dbarton »
|
Logged
|
|
|
|
|
belkira
|
 |
« Reply #5 on: September 12, 2008, 06:04:09 PM » |
|
Im on my way out of work now. I will try to post clearer instructions a little later tonight.
|
|
|
|
|
Logged
|
|
|
|
|
dbarton
|
 |
« Reply #6 on: September 12, 2008, 06:35:38 PM » |
|
Im on my way out of work now. I will try to post clearer instructions a little later tonight.
I rewrote it in simpler terms to try and break it down for me, and this way make sense to me so far... Still, I don't see how I can add a min by min countdown... ;win 2 #2:: SplashTextOn, 250, 20,, preset for 120 mins sleep, 1000 SplashTextOff SetTimer, Message, 7200000 return Message: SetTimer, Message, Off MsgBox ,64 ,dTIMER, 120 minutes is up! return
|
|
|
|
|
Logged
|
|
|
|
|
belkira
|
 |
« Reply #7 on: September 12, 2008, 09:05:51 PM » |
|
You may also want to look at this: http://www.autohotkey.com...highlight=countdown+timerAs for my script, I think you got it but I will break it down in any case. The way I envisioned you using it was thus: Copy/Paste the code into a file, called say Timer.ahk. Put this file someplace out of the way, maybe the root of the C:\ drive. Right click on this file and select Send To| Desktop (Create Shortcut). Now right click on this file (the shortcut) go to Properties and put the number of minutes in after the Target line, i.e.: "C:\Documents and Settings\User\Desktop\Timer.ahk" 120 This way you can create multiple timers all running at once if need be. I will look into the countdown thing, I was thinking you only wanted something that would tell you after a certain amount of time had passed. The program I linked to at the beginning of this post is a countdown timer, but I don't know if it is what you want. Below I have explained the script. I hope it fills in any gaps I may have left. #persistent ; Used to keep the application running long enough to use the timer #singleinstance off ; So you can have multiple instances running %1% := 60 * (%1% * 1000) ; Ok so this is where it gets fun, %1% is the number you give to the program (in minutes). SetTimer uses milliseconds so we have to convert that to seconds, then from there to minutes.
SetTimer, Message, %1% ; Here we tell the timer to wait for X amount of time then run the commands at the given label, in this case Message return
Message: SetTimer, Message, Off ; Here I turn the timer off so it doesn't keep running msgbox Done! ; This is what happens when the timer reaches its mark. ExitApp
-Belkira
|
|
|
|
|
Logged
|
|
|
|
|
dbarton
|
 |
« Reply #8 on: September 12, 2008, 09:17:11 PM » |
|
Much appreciated.
I never thought of using AHK, but it seems to have worked out.. Got a version running by patches a few peoples code togther. Thanks!
|
|
|
|
|
Logged
|
|
|
|
|
belkira
|
 |
« Reply #9 on: September 12, 2008, 09:24:27 PM » |
|
Did you get the countdown part working also? If so I would like to see that part of the code to see how it was done.
|
|
|
|
|
Logged
|
|
|
|
|
belkira
|
 |
« Reply #10 on: September 13, 2008, 12:11:18 AM » |
|
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. [ copy or print] ; ; AutoHotkey Version: 1.x ; Language: English ; Platform: Win9x/NT ; Author: A.N.Other <myemail@nowhere.com> ; ; 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 } } }
|
|
|
|
|
Logged
|
|
|
|
|
dbarton
|
 |
« Reply #11 on: September 13, 2008, 01:32:43 AM » |
|
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
|
|
|
|
« Last Edit: September 13, 2008, 01:47:53 AM by dbarton »
|
Logged
|
|
|
|
|
belkira
|
 |
« Reply #12 on: September 13, 2008, 02:53:41 AM » |
|
The Coords are on this line: 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: Glad you liked it!
|
|
|
|
|
Logged
|
|
|
|
|
dbarton
|
 |
« Reply #13 on: September 13, 2008, 03:28:31 AM » |
|
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 } } }
|
|
|
|
« Last Edit: September 13, 2008, 03:49:27 AM by dbarton »
|
Logged
|
|
|
|
|
belkira
|
 |
« Reply #14 on: September 13, 2008, 04:23:47 AM » |
|
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....
|
|
|
|
|
Logged
|
|
|
|
|
dbarton
|
 |
« Reply #15 on: September 13, 2008, 11:21:02 AM » |
|
That sounds good. Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
dbarton
|
 |
« Reply #16 on: September 20, 2008, 06:11:08 PM » |
|
deleted
|
|
|
|
« Last Edit: September 20, 2008, 06:44:46 PM by dbarton »
|
Logged
|
|
|
|
|
belkira
|
 |
« Reply #17 on: September 20, 2008, 06:57:31 PM » |
|
I was not able to get it to work either.
In looking at the AHK Help file it states that the X,Y can be expressions, but it doesn't say that they can be variables. Maybe for the X,Y on tooltip it doesn't recognize variables.....
|
|
|
|
|
Logged
|
|
|
|
|
dbarton
|
 |
« Reply #18 on: September 20, 2008, 07:10:50 PM » |
|
Sorry I deleted my message because I found the answer. It does accept variables, but the variable wasn't making it into the function. It seems you need to declare that variable in the function as global.
So in my case it was just adding:
countdown(p_count="") { global uY <----------------------- this line 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, uY Menu,Tray,Tip,dTIMEmini remaining: %mmss% ; Tooltip, %uY%, 1, 1, 2 ;MsgBox The value in the variable named uY is %uY%. Sleep, 1000 countdown_date+=-1, s ;//IfLess, countdown_date, 16010101, break if (A_Index>countdown_time) { Tooltip, DONE, 2,uY break
|
|
|
|
« Last Edit: September 20, 2008, 07:12:40 PM by dbarton »
|
Logged
|
|
|
|
|
cranioscopical
|
 |
« Reply #19 on: September 21, 2008, 09:02:19 AM » |
|
Can you not achieve what you want by deploying the existing timer plug-in for Find And Run Robot (FARR)? Timer plugin for FARR
|
|
|
|
|
Logged
|
Chris
|
|
|
|
dbarton
|
 |
« Reply #20 on: September 21, 2008, 12:16:49 PM » |
|
Not sure, but the timers I have seen always set up where you have you enter the time you want *each* time you use it. For people that take medication 2 hrs after eating every day, it's nice to have a timer that has the time value preset.
This is a preset timer, so you just hit the icon, and it counts.
|
|
|
|
|
Logged
|
|
|
|
|
czb
|
 |
« Reply #21 on: September 21, 2008, 12:44:14 PM » |
|
Hi, if you use FARR you can link any hotkey combination to "tm in 2 0 0 take medication". So starting timer would take you to press hotkey hit enter and you are done..
|
|
|
|
|
Logged
|
|
|
|
|
|
|