Windows Programming Made Easy (Why AutoHotkey?)

Never Programmed Before? You’ll Find No Better Language for Learning Than AutoHotkey!

Note: A free scripting language for Window computers, AutoHotkey provides simple techniques for controlling and adding power to your PC. Since today (and into the foreseeable future) Windows PCs continue to represent 90% of the desktop and laptop computers, knowing how to write simple AutoHotkey scripts adds significant experience to anyone’s résumé. Do it for fun and profit!

Languages for Learning to Program

I took a quick look at various sites on the Web recommending languages for learning how to program. You’ve got to be kidding me! I kept seeing lists similar to C, Java, C#, Perl, Ruby, and Python. These may be great recommendations for people who want to become professional programmers, but, if you merely want to make your personal computer more powerful or add useful features to PCs at work, these recommendations represent complex overkill. Anyone new to programming might find these languages incomprehensible—encountering a steep learning curve. Sure they’ll be able to write the infamous beginning code for “Hello, World!”, but the average person who has never coded before soon bogs down in enigmatic syntax (vocabulary) and structure (rules).

ProgrammingRobot
“Why does everyone assume that I know how to program?”
Cartoon by Jim Whiting

Newcomers need easy software which teaches programming basics with each step while returning continuous satisfying results. That way the newbie stays motivated while developing relevant skills. This is where AutoHotkey excels as a beginning language for learning to program.

With AutoHotkey, you can achieve quick, simple, incremental success, yet, if you so desire, ultimately learn all of the concepts, techniques, and tricks valuable in any programming language. You don’t need to make a great leap in understanding to get AutoHotkey working for you. The AutoHotkey learning process is naturally incremental—even without a tutorial. And yet, if you eventually want to create more complex apps, all the capabilities found in the more confusing languages used by the pros appear in AutoHotkey. Plus, if you want to make the leap to other languages later, the underlying principles you learn in AutoHotkey make that jump much easier.

*          *          *

Update: September 14, 2016, Join the ComputorEdge E-Books affiliate sales program and earn extra income on Jack’s AutoHotkey books.

*          *          *

You can start off as a neophyte who merely wants to control actions within your favorite program or game, then, if you continue with the natural process, end up understanding conditional If statements, Loops, and other common programming techniques—without even realizing your progress. The beauty of it is that you learn because you’re doing something useful to you.  Not like school. The only test is whether it works or not…and you’ll know that from the first line of AutoHotkey you write.

AutoHotkey Gives Novices Instant Results

Beginner's Guide to AutoHotkeyThe lifeblood of a programmer’s motivation is making the code work. When the coder eventually gets a routine running, there is an overwhelming desire to tell someone about the success. Sadly, few people understand enough programming to appreciate the brilliance of the achievement. (Too often programmers find themselves telling people about their cool, new routine only to be greeted with blank stares.) AutoHotkey not only provides quick results, but other non-computer people can appreciate the new features added to their Windows computer.

Unlike most other programming languages, AutoHotkey includes two programming structures which give results with as little as one line of code: Hotkeys and Hotstrings.

AutoHotkey Hotkeys

Hotkeys are key combinations which activate an action. For example, the key combination CTRL+L can be assigned to open a Google search page:

^l::run, http://google.com

This one line acts as a stand-alone app. Press the CTRL key and the L key simultaneously and Google search opens in your default Windows browser.  (The caret ^ represents the Control key. The double-colon :: makes it a Hotkey.) After saving this one line of coded in a text file with the AHK script extension, then loading it with the free open-source AutoHotkey program running on your Windows computer, the key combination immediately activates the Web page. (To get started with AutoHotkey, see “Installing AutoHotkey and Writing Your First Script.”) Easy to test and easy to see results.

Suppose you want a shortcut for opening the Windows Calculator program:

^m::run, calc

After loading, CTRL+M (^m) launches the Windows Calculator (run, calc). Another one-line app.

Tip: If you have kids in the house, make it simple for them to launch their favorite “educational” program themselves by adding it to an AutoHotkey Hotkey script.

This only scratches the surface of what AutoHotkey can do with Hotkeys. Plus, these Hotkeys work in any Windows program or Web page. No other programming language makes producing useful Windows scripts so simple. But, wait! There’s more!

AutoHotkey Hotstrings for Text Expansion and Correction

Another useful AutoHotkey technique similar to Hotkeys which proves just as simple while providing instant gratification includes Hotstrings. Similar in structure to Hotkeys, Hotstrings provide instant text manipulation and replacement:

::lol::laugh out loud

A double-colon :: always precedes and follows the AutoHotkey activating Hotstring. The replacement text follows the second-double colon. After typing the activating string, followed by a space or punctuation, AutoHotkey deletes the activating string, substituting the replacement text. In this case, the one line of code (after loading the script on a Windows computer) replaces the typed characters “lol” (followed by a space or punctuation) with the text “laugh out loud” instantly in any document, editing window, or Web page.

Each line represents a stand-alone app. When building an autocorrect script, immediately correcting “teh” to “the” only requires the line:

::teh::the

(See “Add AutoCorrection to All Your Windows PC Programs with AutoHotkey” for many more autocorrect examples.) In most cases, AutoHotkey Hotkeys and Hotstrings can be added to the same file with little regard for their order.

Do As Little Or As Much As You Like

If you only use AutoHotkey to write Hotkey and Hotstring scripts, then you’ve done way more to add power to your Windows PC, than most people ever do. AutoHotkey includes most of the same capabilities for writing applications as any other programming language, but you don’t need to venture directly into those more complex areas—unless you get hungry for more. (For a taste of other possible AutoHotkey scripts and apps, see “Free AutoHotkey Scripts and Apps for Learning Script Writing and Generating Ideas.”)

You can learn as little or as much AutoHotkey as the motivation strikes you. However, in the course of writing books about AutoHotkey, I often found that each little piece I added to a script sparked new ideas for more cool features. That motivated me to move on to the next step—looking up more commands for adding that next bit. It’s easy to tinker with an old script (or someone else’s example) just to see how it reacts. I learned more from playing around with scripts than I have from reading about the commands online. True understanding of the nuances of a command comes from using it.

Maybe you’ll stop after adding a few useful Hotkeys/Hotstrings to your Windows computer. But if you keep adding to your scripts, you’ll learn more about programming than you ever thought possible. Rather than learning AutoHotkey all at once, you can grow into it. You can keep your apps simple or add as many features as you like. But, be careful! Too much tinkering may get you hooked.

AutoHotkey Is an Easy-to-Read Language

In some programming languages, the commands can look pretty cryptic. In AutoHotkey, most command and parameter names immediately suggest their function. MsgBox opens a message box. Run runs an app or opens a Web page. SetTimer starts a timer clock. This makes the commands easier to both understand and remember.

For experienced programmers this probably isn’t a significant point. When working with a new language, they know what type of command they want and have a pretty good idea where to look. But for the new or casual script writer, this type of easy reading commands may make the difference between getting a script running and giving up in frustration.

Forgiving Structure and Syntax

In most programming languages, the layout of a program file and writing of each command line must follow an exact format. If you don’t get it right, nothing works. While not totally without its own formatting issues, AutoHotkey doesn’t care about capitalization, the order of options in commands, and occasionally overlooks the dropping of a comma (e.g. the MsgBox command). This makes it a little easier for the newbie.

Note: AutoHotkey has a number of critical formatting issue in both script layout and command structure, but for the most part when starting out with Hotkeys and Hotstrings, formatting rarely present a problem (with the exception of the placement of double-colons).

Everything You Need Is on the Web…Mostly

Some people have a knack for computer coding. From the time they first look at a script, it immediately makes sense to them. They easily jump from one programming language to another. There might be a slight learning curve with the different vocabulary (systax) used in various languages, but that’s just a matter of grasping the new jargon. It seems that their brain is networked for the logic of If statements and Loops.

For these computer savants, the Web provides everything they need through AutoHotkey documentation, forums, and help sites. They read the command definitions and immediately know what to do. They rarely need any extra help. (Admittedly, I have seen people operating at this high level pose questions on the AutoHotkey forums, but I often don’t understand the question—much less the answer.) However, not everyone learns in the same way.

Since the my first look at AutoHotkey, I’ve attempted to make my writing a gentle introduction into the free Windows scripting language. Other than as a possible reference or idea generator, my books are not aimed at the professional programmer. The books are designed to aid the neophyte Windows script writer. If you’re interested in taking a closer look at writing AutoHotkey scripts, but don’t want to spend hours digging through the Web for the answers or don’t feel totally comfortable with the idea of writing Windows scripts, then my book A Beginner’s Guide to AutoHotkey might give you the start you want.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s