; ; AutoHotkey Version: 1.x ; Language: English ; Platform: Win9x/NT ; Author: A.N.Other ; ; 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. #SingleInstance Force IniRead, Howmany, C:\Users\%A_UserName%\Documents\GrandKids\GrandKids.ini, Settings, Number Loop, %Howmany% { IniRead, First, C:\Users\%A_UserName%\Documents\GrandKids\GrandKids.ini, Grand%A_Index%, First IniRead, Second, C:\Users\%A_UserName%\Documents\GrandKids\GrandKids.ini, Grand%A_Index%, Second IniRead, Last, C:\Users\%A_UserName%\Documents\GrandKids\GrandKids.ini, Grand%A_Index%, Last IniRead, Birthday, C:\Users\%A_UserName%\Documents\GrandKids\GrandKids.ini, Grand%A_Index%, Birthday HowOld(Birthday,A_Now) FormatTime, Birthday , %Birthday%, dddd, MMMM d, yyyy RowSpace := First . " " . Second . " " . Last . " " RowSpace := SubStr(RowSpace,1,35) BDSpace := Birthday . " " BDSpace := SubStr(BDSpace,1,40) Gui, Add, Text, , %RowSpace%`t%BDSpace%`t%Years% Years, %Months% Months, %Days% Days } FormatTime, Now_Time, , Longdate Gui, show, w575 ,Grand Kids -- %Now_Time% HowOld(FromDay,ToDay) { Global Years,Months,Days ; If born on February 29 If SubStr(FromDay,5,4) = 0229 and Mod(SubStr(ToDay,1,4), 4) != 0 and SubStr(ToDay,5,4) = 0228 PlusOne = 1 ThisMonth := SubStr(ToDay,1,6) ; Set ThisMonthLength equal to next month ThisMonthLength := % SubStr(ToDay,5,2) = "12" ? SubStr(ToDay,1,4)+1 . "01" : SubStr(ToDay,1,4) . Substr("0" . SubStr(ToDay,5,2)+1,-1) ; Days in this month saved in ThisMonthLength EnvSub, ThisMonthLength, %ThisMonth%, d ; Set ThisMonthday to FromDay or (if FromDay higher) last day of this month If SubStr(FromDay,7,2) > ThisMonthLength ThisMonthDay := ThisMonth . ThisMonthLength Else ThisMonthDay := ThisMonth . SubStr(FromDay,7,2) ; Calculate last month's length LastMonthLength := % SubStr(ToDay,5,2) = "01" ? SubStr(ToDay,1,4)-1 . "12" : SubStr(ToDay,1,4) . Substr("0" . SubStr(ToDay,5,2)-1,-1) LastMonth := LastMonthLength ; Days in last month saved in LastMonthLength EnvSub, LastMonthLength, %ThisMonth% ,d LastMonthLength := LastMonthLength*(-1) ; Set LastMonthday to FromDay or (if FromDay higher) last day of last month If SubStr(FromDay,7,2) > LastMonthLength LastMonthDay := LastMonth . LastMonthLength Else LastMonthDay := LastMonth . SubStr(FromDay,7,2) ; Calculate years Years := % SubStr(ToDay,5,4) - SubStr(FromDay,5,4) < 0 ? SubStr(ToDay,1,4)-SubStr(FromDay,1,4)-1 : SubStr(ToDay,1,4)-SubStr(FromDay,1,4) ; Calculate months Months := % SubStr(ToDay,5,2)-SubStr(FromDay,5,2) < 0 ? SubStr(ToDay,5,2)-SubStr(FromDay,5,2)+12 : SubStr(ToDay,5,2)-SubStr(FromDay,5,2) Months := % SubStr(ToDay,7,2) - SubStr(ThisMonthDay,7,2) < 0 ? Months -1 : Months Months := % Months = -1 ? 11 : Months ; Calculate days TodayDate := SubStr(ToDay,1,8) ; Remove any time portion of stamp EnvSub, ThisMonthDay,ToDayDate , d EnvSub, LastMonthDay,ToDayDate , d Days := % ThisMonthDay <= 0 ? -1*ThisMonthDay : -1*LastMonthDay ; If February 28 Years := % plusone = 1 ? Years +1 : Years days := % plusone = 1 ? 0 : days If (TodayDate <= FromDay) Years := 0, Months := 0,Days := 0 }