Build Your Own AutoHotkey Command Reference Tool (An AutoHotkey Secret)

November 1, 2016: Just as I was marching off in another direction, one more check of the AutoHotkey.com site surprised me. The hidden indexing feature discussed in this blog started working again. Go figure! Will it last? Who knows? But for now, this blog is valid again. I’ll now be able to introduce the AutoHotkey Quick Reference tool I had started working on. 

October 26, 2016: I don’t know if it’s temporary or permanent, nor do I know why, but much of the AutoHotkey Web site index capability (if not all) discussed in this blog has been disabled. I don’t know the rationale for the change or if it may return, but it was a great aid to anyone doing AutoHotkey scripting while it lasted. (One week for me from my point of discovery to its disappearance.) Stranger things have happened. Needless to say, I’m back to browser searches for AutoHotkey URLs.

Learn a Hidden AutoHotkey Trick for Quickly Accessing AutoHotkey Online Command Information

Occasionally (completely by accident), I come across surprising, eye-opening tips. In my last blog, I used an AutoHotkey script to access an online thesaurus by merely highlighting robotsecretcartoona word and hitting the assigned Hotkey. I began checking other Web sites for how easily I could run a similar site search. Naturally, since I include links to the Web reference commands in virtually every blog I write, I checked out AutoHotkey.com. In the process, I uncovered a remarkable secret.

Sometimes a secret exists not due to someone wanting to keep it hidden, but only because no one has mentioned it. That’s the case with this week’s topic. I stumbled upon a feature of the AutoHotkey Web site which makes its excellent documentation even more accessible—especially if you take advantage of it while writing AutoHotkey scripts. If you’re a regular AutoHotkey user, then you’ll love this one! (This tip is worth telling all your AutoHotkey friends—if they haven’t discovered it for themselves.)

*          *          *

New to AutoHotkey? See “Introduction to AutoHotkey: A Review and Guide for Beginners.”

*          *          *

AutoHotkey.com Documentation

The online AutoHotkey documentation and command reference is as good as any I’ve ever seen for a programming language. From day one, I’ve relied upon it heavily to both learn how to write scripts, as well as, use as the primary reference for my blogs and my books. The documentation is so good that with the aid of this resource most users can teach themselves AutoHotkey scripting—especially the basics. That’s one of the reasons that I avoid regurgitating command syntax—spending more time on practical applications and the nuances of AutoHotkey which don’t necessarily appear online. There’s no point in me restating what can easily be found at the site. My recent discovery has only increased my respect for the online AutoHotkey documentation and the detailed work done by the site’s designer(s). (If I knew who was the responsible party, I would certainly give credit.)

The first hint of this hidden AutoHotkey.com feature revealed itself to me when I noted the results of my entering a possible search term in the browser address field. I was merely testing Web page reaction to my adding an AutoHotkey command directly into the basic URL. (I know that Linux servers are often case-sensitive to typed URLs.) I inserted the word “sleep” (without an initial cap or the .htm extension) to the basic documentation address:

https://autohotkey.com/docs/sleep

AutoHotkey immediately redirected me to the Web page:

https://autohotkey.com/docs/commands/Sleep.htm

This surprised me because the site had essentially corrected my built-in URL syntax error and launched the correct page. A light in my head flipped on. I tested “ifwinactive”:

https://autohotkey.com/docs/ifwinactive

and it returned the page:

https://autohotkey.com/docs/commands/WinActive.htm

listing all the associated commands with the complete discussions.

Interestingly, the automatic command conversion and page loading only occur when using the https://autohotkey.com/docs/[command] URL. Neither https://autohotkey.com/[command] nor https://autohotkey.com/docs/commands/[command] work. Just dumb luck that I tested the right one.

I typed in “continuation” looking information on line continuation (the word wrapping of unusually long command statements):

https://autohotkey.com/docs/continuation

AutoHotkey jumped to:

https://autohotkey.com/docs/Scripts.htm#continuation

the topic “Splitting a Long Line into a Series of Shorter Ones.” In fact, I could quickly access almost any AutoHotkey command, variable, or topic by adding the appropriate word to the basic documentation URL in the browser address field and hitting RETURN. I entered:

https://autohotkey.com/docs/a_now

getting:

https://autohotkey.com/docs/Variables.htm#Now

which jumps within the loaded Variables.htm page directly to the A_Now  variable and its associated explanation. This technique showed me the internal page link (#Now)—which is not easy to identify for inclusion in my blog—at least, not without looking at the page source code. Even slightly off syntax works, such as when I looked for the built-in variable for the week of the year:

https://autohotkey.com/docs/week

took me to the documentation for the built-in variable A_YWeek— the current year and week number (e.g. 200453)):

https://autohotkey.com/docs/Variables.htm#YWeek

If I misspelled the keyword or tested a term not included in the site index, AutoHotkey.com would launch a Google search of the site which usually yielded the page I wanted.

The AutoHotkey site is indexed for most keywords in the documentation. This site feature sparks a wide range ideas for script writing reference tools using—yes—AutoHotkey.

AutoHotkey Reference Script for AutoHotkey Commands, Variables, and Documentation

I quickly created an AutoHotkey reference tool by inserting the new URL into the Web search structure from last time:

^!m:: ; open AutoHotkey.com
  OldClipboard:= ClipboardAll
  Clipboard:= ""
  Send, ^c ;copies selected text
  ClipWait 0
  If ErrorLevel
  {
     MsgBox, No Text Selected!
     Return
  }
  Run https://autohotkey.com/docs/%Clipboard%
  Clipboard:= OldClipboard
Return

Now, whenever I need to find the URL for an AutoHotkey command, I merely highlight the command in the blog and hit the Hotkey combination CTRL+ALT+m (^!m). In most cases, the correct page opens in my default Web browser. Worst case, AutoHotkey launches a Google search of the site usually listing the desired page at the top.

This type of AutoHotkey reference script acts as a tremendous timesaver for anyone who writes AutoHotkey apps. If you’re stuck on how to use a command, simply highlight it and hit the activating key combination. Or, reviewing someone else’s script and come across an unknown command? Select the text and hit the Hotkey. The little-known fact that the Web designer(s) indexed the AutoHotkey.com site with commands and common keywords adds tremendous power to the online resource.

Ironically, AutoHotkey scripts can make the best use of this secret AutoHotkey site feature. You’ll find numerous ways to take advantage of it. Next time, I discuss a new AutoHotkey reference tool I wrote which automatically pops up a window with the correct syntax for any command, then offers the option to open the page in your Web browser.

Update November 6, 2016: I’ve started on an AutoHotkey Quick Reference tool using this hidden index at the AutoHotkey.com site.

jack

*          *          *

If you find Jack’s AutoHotkey Blogs useful, then please consider contributing by purchasing one or more of Jack’s AutoHotkey books. The e-books make handy AutoHotkey references.

 

 

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 )

Connecting to %s