New Hotkey Book! (AutoHotkey Tips and Tricks)

AutoHotkey Techniques and Best Practices E-Book for Automating Your Windows Computers with Hotkey Combinations—Includes Something for Everyone!

Whether you’re a noobie to AutoHotkey scripts or an advanced programmer, of all my books, AutoHotkey Hotkeys may be the most important for new little-known tricks and useful ideas. It’s not that the other books don’t cover significant features of AutoHotkey, but this book includes some of the most practical tips for adding power to your scripts. I didn’t plan it that way.

*          *          *

Composed of updated and edited articles which originally appeared in this blog, the book AutoHotkey Hotkeys provides a convenient reference in e-book formats (EPUB, MOBI for Kindle, and PDF) for any AutoHotkey script writer. For anyone confused about what AutoHotkey books or which e-book formats are right for them, ComputorEdge E-Books now offers an AutoHotkey Library Bundle of all seven books in all three formats for a reduced price.

*          *          *

hotkeycover200In the course of writing the individual chapters I experienced a number of personal epiphanies. A few “Best Practices” slowly materialized as I worked with central commands. The power of #IfWin directives opened my eyes as I searched for practical examples. The usefulness of keyboard Scan Codes versus Virtual keys became apparent once I understood how they work. Plus, the book writing process sparked insight into making any AutoHotkey command more powerful with forced expressions (%) and the ternary operator.

The book starts at a beginning level (Chapter One), but it quickly builds upon that basic Hotkey structure to introduce more advanced techniques—including detailed discussions of the unique Hotkey command. Writing this book turned into a voyage of discovery. I merely followed where the AutoHotkey commands and features led me.

Hotkey Best Practices

I didn’t introduce the concepts which I now recognize as “Best Practices” until Chapter Fifteen. Prior to that, even though I had discussed the relevant techniques, the working details of those commands consumed my focus. Only after I started working on the Hotkey summary script MousePrecise.ahk did it dawn on me that I could and should apply a few of these tricks to virtually all my AutoHotkey Hotkey scripts. From those insights sprang a few thumb rules.

Thumb Rule #1: Whenever possible isolate Hotkey functions to only those programs (windows) where you need them.

The  IfWinActive command (Chapter Two) and the #IfWinActive directive (Chapter Three) act as the primary methods for restricting context-sensitive Hotkeys to particular apps and windows .

Thumb Rule #2: Save code and add flexibility to the #IfWinActive directive by using the GroupAdd command for including more programs in the Hotkey restrictions.

Using the GroupAdd command to add programs classes to the InWinActive/#IfWinActive statements overcomes the command/directive’s inherent inflexibility (Chapter Four).

Thumb Rule #3:  Make a habit of adding important Hotkey actions to the System Tray icon menu.

If you use numerous Hotkeys, it only makes sense to add them to the System Tray icon right-click menu (Chapter Twenty). Otherwise, you may find it impossible to remember them all.

Thumb Rule #4: When using the Windows Clipboard for copying selected text, add basic structure which includes standard commands.

In the years that I’ve used AutoHotkey, I found that a number of command lines should be part of any standard clipboard manipulation routine. Those techniques include saving contents of the Windows Clipboard (ClipboardAll) for later restoration, waiting for the clipboard to load (ClipWait command), and using ErrorLevel for Hotkey misfires. Chapter Nine explains how to implement each of these techniques when using the Windows Clipboard to trigger AutoHotkey routines and manipulate text.

Understanding and Using #Directives

New AutoHotkey users often struggle with the difference between regular commands and #Directives. Using the wrong one at the wrong time doesn’t work—and errors may not be obvious. Chapter Three discusses “Commands Versus #Directives.”

The Power of Forced Expressions and the Ternary Operator

Occasionally, I experience an insight which has a profound impact on how I write AutoHotkey commands. One such revelation inspired by AutoHotkey forced-expressions brings my scripts to the next level. This realization may be the single most important capability for adding conditional features to any AutoHotkey command.

AutoHotkey Library Deal
Jack’s AutoHotkey Library Deal

“Hey! Pay attention! This part is really important!” Forced expressions—especially in combination with the single-line Ternary Operator can add incredible power to virtually any AutoHotkey command. Forced expressions initiate the jump from staid fix syntax formats and options to flexible conditionals embedded inside a command. Chapter Seventeen, “Force an Expression (%) in AutoHotkey for More Powerful Commands” and Chapter Eighteen, “AutoHotkey Toggles and the Ternary Operator” offer tricks that any AutoHotkey user will want to know.

Keyboard Scan Codes Versus Virtual Keys

A book about AutoHotkey Hotkeys wouldn’t be complete without a discussion of keyboard Scan Codes and Virtual Keys. Chapter Twelve, “Understanding AutoHotkey Keyboard Scan Codes and Virtual Key Codes” highlights the difference between AutoHotkey Keyboard Scan Codes (SCnnn) and Virtual Key Codes (VKnn) and when to use them for Hotkeys. Then to offer practical examples, Chapter Thirteen uses methods for writing toddler educational Hotkey scripts. Plus, the follow-on chapters about the MousePrecise.ahk script make extensive use of these special key codes.

AutoHotkey Tricks Found in the Book

  • Blocking evil Windows shortcuts (Chapter Two)
  • Keyless Hotkey volume control (Chapter Six)
  • Standardizing Hotkey (shortcut) actions across multiple applications (Chapter Seven)
  • Toggling Hotkeys on and off (Chapter Eight)
  • ErrorLevel tricks with Hotkeys (Chapter Ten)
  • Using the Tooltip command and a quick release Hotkey (Chapter Nineteen)
  • Using the extra mouse buttons—XButton (Chapter Twenty-one)
  • And more…

The AutoHotkey.com Secret Reference

I consider the hidden index I stumbled upon at AutoHotkey.com so useful that I wrote an AutoHotkey Quick Reference script based upon it. I include a chapter on this site feature in this book (Chapter Twenty-two) and intend to do the same as I update each of the other books—at least until the secret index disappears again.

While this book focuses on Hotkeys, you’ll find numerous AutoHotkey tips and tricks valuable for most of your other scripts.

 

jack

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s