ezuk
Joined: 04 Jun 2005 Posts: 122
|
Posted: Sun May 25, 2008 5:42 pm Post subject: Losing weight with AHK |
|
|
One of the most important things you could do to lose weight (at least from my own experience) is to log your weight every day. You could then use the formula from The Hacker's Diet to see if you really are losing weight.
However, weighing in every morning can be a hassle. It's easy to forget, and not very convenient.
To solve this, I made a script which overlays your screen with a dark, full screen window, and forces you to enter your current weight before you can begin using the computer for the day. It is supposed to be run as a scheduled task (early in the morning, before you get on your computer) or on Startup.
You can also enter notes.
The script uses a special GUI, because I wanted it to be pretty. I'm quite pleased with it. It's also compatible with a dual-monitor setup (dims both monitors).
You cannot Alt-Tab away from the script, or close it in any other way (short of turning the computer off). The only way to exit the script is by typing three digits (your weight, to a decimal point) and hitting ENTER.
Your data gets saved to a tab-delimited file.
Note: As always, you might have to tweak it to get it to work. I'm not promising it'll work correctly on any and all systems.
Screenshot:
Code:
| Code: |
Logfile = WeightLog.txt
SetTimer,KillTaskMgr,10
Gui, +LastFound +AlwaysOnTop -Caption +Owner ; +Owner stops taskbar button appearing.
Gui, Color, 000000
WinSet, Transparent, 200
Gui,Font,cYellow wBold s50,Verdana
Gui, Add, text,x0 w%A_ScreenWidth% center y200, Good morning.
Gui,Font,s20 cWhite wNorm
Gui,Add,Text,x0 w%A_ScreenWidth% center, Please enter your current weight to proceed.
Gui,Font,s13
Gui,Add,Text,x0 yp+40 w%A_ScreenWidth% center, (Hit n to make a note.)
Gui,Font,s130 cWhite wBold
Gui,Add,Text, section yp+17 x540 vFirstDigit,
Gui,Add,Text, ys x730 vSecondDigit,
Gui,Font,s130 cYellow
Gui,Add,Text,vDot ys x910,
Gui,Font,s130 cWhite
Gui,Add,Text,vThirdDigit ys x1020,
Gui,Font,s20 cWhite italic w300
Gui,Add,Text,yp+205 x0 w%A_ScreenWidth% center vnote,
Gui,Font,norm cYellow wBold s50,Verdana
Gui,Add,Text,yp+50 x0 w%A_ScreenWidth% center vthanks,
Gui,Font,s20 cWhite wNorm
Gui,Add,Text,yp+100 x0 w%A_ScreenWidth% center vconf,
Gui, Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth%
SysGet,Mon2,Monitor,2
Gui,2:Default
Gui, +LastFound +AlwaysOnTop -Caption +Owner ; +Owner stops taskbar button appearing.
Gui, Color, 000000
WinSet, Transparent, 200
Gui,Show, x%Mon2Left% y%Mon2Top% h%Mon2Bottom% w%Mon2Right%
Gui,1:Default
Numpad0::0
Numpad1::1
Numpad2::2
Numpad3::3
Numpad4::4
Numpad5::5
Numpad6::6
Numpad7::7
Numpad8::8
Numpad9::9
0::
1::
2::
3::
4::
5::
6::
7::
8::
9::
GuiControlGet,FirstDigit
If (FirstDigit < 0)
{
GuiControl,Text,FirstDigit,%A_ThisHotkey%
Return
}
GuiControlGet,SecondDigit
If (SecondDigit < 0)
{
GuiControl,Text,SecondDigit,%A_ThisHotkey%
GuiControl,Text,Dot,.
return
}
GuiControlGet,ThirdDigit
If (ThirdDigit < 0)
{
GuiControl,Text,ThirdDigit,%A_ThisHotkey%
GuiControl,Text,thanks,Thank you.
GuiControl,Text,conf,Please hit Enter to confirm.
return
}
return
NumPadSub::
~BackSpace::
IfWinNotActive, Enter Note
{
GuiControlGet,FirstDigit
GuiControlGet,SecondDigit
GuiControlGet,ThirdDigit
If (ThirdDigit > -1)
{
ThirdDigit =
GuiControl,Text,ThirdDigit
GuiControl,Text,Conf
GuiControl,Text,thanks
Return
}
If (SecondDigit > -1)
{
ThirdDigit =
GuiControl,Text,SecondDigit
GuiControl,Text,Conf
GuiControl,Text,thanks
Return
}
If (FirstDigit > -1)
{
ThirdDigit =
GuiControl,Text,FirstDigit
GuiControl,Text,Conf
GuiControl,Text,thanks
Return
}
}
return
NumPadEnter::
Enter::
IfWinActive Enter Note
{
Gosub,UpdateNote
return
}
GuiControlGet,FirstDigit
GuiControlGet,SecondDigit
GuiControlGet,ThirdDigit
If (ThirdDigit > -1)
{
GuiControlGet,Note
FormatTime,Today,,ShortDate
StringToWrite = %Today%`t%FirstDigit%%SecondDigit%.%ThirdDigit%`t%note%`n
FileAppend,%StringToWrite%,%Logfile%
ExitApp
}
Return
$n::
GuiControlGet,note
IfWinExist,Enter Note
sendinput,n
IfWinNotExist,Enter Note
{
Gui,3:Default
Gui,Font,s30
Gui,Color,4a4a4a
Gui,Add,Edit,vNote w1000,%note%
Gui,+AlwaysOnTop -Caption +Owner
Gui,Show,center,Enter Note
}
return
!F4::
Lwin::
Rwin::
^Esc::
+^Esc::
!^Del::
!Space::
!Tab::
return
UpdateNote:
GuiControlGet,note,3:
Gui, 3: Destroy
GuiControl,Text,note,%note%
return
KillTaskMgr:
IfWinExist,Windows Task Manager
WinClose,Windows Task Manager
return
GuiClose:
Exitapp
|
|
|