Remember All Your Grand Kid’s Birthdays and Their Ages! There’s No Limit to the Number of Ways You Can Amuse Your Grandchildren with AutoHotkey, Plus It Gives Your Brain a Much Needed Workout!

If you only have one grandchild, then you probably won’t have much trouble recalling his or her birthday or age. In that case, you may not have much interest in the little AutoHotkey GrandKids.ahk script. However, AutoHotkey offers much more which can enrich your offspring’s offspring’s education and entertainment—including a one-line script which verbalizes out loud the letters and numbers on the computer keyboard. But more importantly, learning to write AutoHotkey scripts exercises your mind—something everyone needs.

* * *

Some of the scripts in this blog may not make AutoHotkey look easy, but you’ll find the first steps to AutoHotkey literacy quite simple. For a comfortable startup, check out this Introduction to AutoHotkey.

* * *

AutoHotkey Library Deal

One of the most daunting tasks for any grandparent involves remembering and acknowledging the birthdays of your grandchildren—especially if you have a plethora of them. Forgetting the birth of a grandkid falls among the greatest sins that a family elder can commit. You may need a computer to keep track of them all. Fortunately, AutoHotkey makes it easy.

Remembering Birthdays and Ages

You may use the calendar on a computer or smart phone to remind you of approaching birthdays, but they don’t usually tell you the age of the honoree. Even then, to find the exact day, you must sift through the months searching for each birthday. What if you could add all the names and dates to one short file, then run an app which listed all of the birthdays and the exact age of each child (down to the day)? The AutoHotkey GrandKids.ahk script does that!

The GrandKids.ahk app lists birthdays and the age of each child calculated to the day. (This script works equally well for any other commemorative dates.)

Activate the Hotkey combination and a window pops up—automatically calculating the ages.

As you can see, Lyla turned five on Valentine’s day (5 Years, 0 Months, 0 Days). (The surprise came when I noticed the fast approach of Anya’s birthday.) This app comes in handy when you ask “Now, how old is he/she?” AutoHotkey uses the names and dates stored in an INI file (GrandKids.ini) which opens with any text editor (Notepad?).

I take particular pride in the AutoHotkey function for calculating the difference between two dates in years, months, and days (HowOld(FromDay,ToDay)). Working with dates always presents a challenge since the increments (e.g. number of days or months in a year, number of days in each month) are not particularly rational. I struggled with the date calculations until I finally nailed the function. (Not for the faint of heart, but it added one year to my brain life. Three chapters included as one section of the e-bookDigging Deeper Into AutoHotkey explain the evolution of the GrandKids.ahk script and the HowOld() function.)

For a simpler AutoHotkey app, let’s make the keyboard talk.

A Simple One-Line Script to Teach the Computer Keyboard and Alphabet

Kids love noise—even if educational! I’ve played with a number of AutoHotkey scripts which activate the Windows voice feature to both read sentences and repeat keyboard key names (more on that later). But, only the other day I came up with an elegant one-line solution for turning the Windows keyboard into an educational tool. (Actually, you might need to add one additional line to a stand-alone script since AutoHotkey must install the keyboard hook for the A_PriorKey variable to work.)

When running an AutoHotkey script with the keyboard hook installed, the last key pressed automatically gets stored in the variable A_PriorKey. (I didn’t realize this until a recent exploration of the online AutoHotkey documentation.) In the past, I had worked on keyboard scripts which required me to list each individual key with a new line of code. (Tedious.) Now, with the A_PriorKey variable, I can condense it all down to a one-line Hotkey:

~Space::ComObjCreate("SAPI.SpVoice").Speak(A_PriorKey)

Once loaded, a grandchild can push any keyboard key, then press the SPACEBAR. The computer speaks the key out loud. While this seems incredibly mundane, for grandchildren getting their hands on Grand Dad’s “big” computer is a huge deal.

The squiggle (~) before the SPACEBAR key (~Space) causes the key’s purpose to pass through to its original function—entering a space into any document—without getting blocked. That way you can continue writing and editing without exiting the script. However, every time you hit the SPACEBAR, the computer speaks the last character you keyed. To prevent this, you may want to use another less important key such as CAPSLOCK:

~CapsLock::ComObjCreate("SAPI.SpVoice").Speak(A_PriorKey)

Note: While you don’t need to understand exactly how the keyboard hook works, it must install before using the A_PriorKey variable. In scripts, the appearance of any Hotstrings or Hotkeys automatically installs the keyboard hook or you can set it unconditionally with the follow directive:

Once you get into AutoHotkey (which you should for the sake of your mental longevity), you’ll find even more ways to entertain and educate the youngsters.

More AutoHotkey Entertainment and Education

The SayWhat.ahk script demonstrates how you can easily use the text reading capability of Windows in an AutoHotkey script. Once loaded, the script opens the “Speak to Me!” window. Type in any text, then click “Talk!” The default Windows voice reads the text out loud.

NumbersSpeak.ahk contains, cow-skating.jpg (image file) and cow-madcow.wav (audio file). The NumbersSpeak.ahk script uses the SayWhat.ahk script as a basis for exploring techniques in writing children’s educational software. Press the letter C, and the script displays the SplashImage (shown above), reads the words “C is for cow!”, then spells “c – o – w”, followed by the sound of a laughing mad cow mooing. Using the SplashImage and SoundPlay commands, plus the ComObjectCreate() functionComObjCreate(“SAPI.SpVoice”).Speak(), this example had my grandkids rolling in the aisles. (I discuss this script in Chapter Thirteen of AutoHotkey Hotkey Techniques.)

While far from complete, the script features some of the AutoHotkey tools available for building cute children’s scripts. It is an apt companion for the educational TalkingText.ahk script which voices the letters of the keyboard, then makes animal sounds when spelling certain animal names (e.g. cat, dog, bear, and more).

Exercise the Brain

While there have been a number of studies about what happens to the human brain in later years, most are inconclusive—especially when it comes to what to do about it. It seems that regular physical exercise helps, but the jury is out on how much various types of mental stimulation assist. However, most articles conclude that any form of cerebral gymnastics is “better than nothing” or “It can’t hurt!”

From Time, “Games sure seem like a good way to work your brain out, but don’t put your stock in Sudoku. ‘They target very specific cognitive abilities, but they don’t transfer to clarity of thinking, problem solving, planning—all the complex skills that really matter,’ explains Dr. Sandra Bond Chapman, chief director of the Center for Brain Health at the University of Texas at Dallas and author of Make Your Brain Smarter.”

“Along with aerobic exercise, engaging your brain in complex ways is absolutely necessary to keep your mind sharp in the second half of life.” Studies have found few links between doing puzzles such as crossword and Sudoku and staving off mental deterioration. However, it may be that learning to write programs or computer scripts offers everybody increased cerebral longevity.

Several studies have shown that being bilingual or multilingual significantly delays the manifestation of Alzheimer’s because bilingual brains have greater adaptability and functionality. So are programmers’ brains similarly resistant to developing the disease?

“We found [the] first empirical evidence that both, natural language and programming language, require the same areas in the brain,” she said. “Based on this, we can infer that understanding programming languages and natural languages appear to be similar.”

While not definitive, I’ve decided not to wait until science proves whether or not mental stimulation (and which type) actually helps keep my brain in shape. I’ll continue doing crossword puzzles (and cheating via the Web) and exploring new ways to apply AutoHotkey on my Windows computer. I recommend that you do the same.