AutoHotkey Love Letter & Beginner Tutorial

in #autohotkey8 years ago

I've had a growing obsession with AutoHotkey (AHK) for 6 years now. AutoHotkey is a free automation program that uses your keystrokes & mouse-clicks to trigger pre-defined keystrokes & mouse-clicks that are sent to your computer - effectively triggering additional typing & multiplying your work output. You can get more done, more quickly, more accurately.

Most of my work with AHK has been at my day job (I work in the insurance industry, spending most of my workday managing information and redirecting emails between various companies). I started using AHK for easy text replace scripts (pressing just 3 keys - G M {TAB} - types Good Morning). After using that nifty hack for a few hours, I had an epiphany - it began to dawn on me just how much of my email content could be automated. I quickly added a ton more scripts like the above (so many, in fact, it became a job in itself to remember all the new shortcuts!). Thus began my love affair with AutoHotkey. But the rabbit hole didn't end with making emails way simpler to type. I began to learn more of the AHK scripting language and started stringing together what I termed "workflows", basically sequencing mouse clicks & keyboard strokes to knock out more complex data entry & paperwork processing scenarios. I'll go into those in a future post, for sure..

For now, though, I am putting down this beginner tutorial so that anyone can learn to use this amazing program. Besides the time saved doing menial, mind-numbing tasks, I've found working with AutoHotkey is an EXCELLENT way to dip your feet into programming. Its scripting language is simple, direct, and the results are instant. Since you already know what job tasks are robotic in nature (click this, type that, {TAB} there, {ENTER} when that screen comes up), it is very easy to translate them to commands in your script. Once you become comfortable with AutoHotkey, it adds another whole layer of creativity to your workday and to even the most repetitious, soul-killing tasks. Take it seriously and you will get more done in shorter and shorter amounts of time than any person could possibly do on their own, all the while learning basics of programming and embodying the ethic of 'work smarter, not harder'.

So, lets get down to it.. All you really need to start is the software, which can be downloaded from autohotkey.com, and Notepad (or any other text editor). I have only used this on Windows, and am not sure if it, or any similar software, exists for other systems.

We'll start where I did in the beginning.. Good ol' GM..

::gm:: 
Send Good Morning
return

Once you've installed AutoHotkey software, open your script in Notepad. Copy & paste the above code into it. Save the file. Right-click the green/white H icon (bottom-right on Windows taskbar) and hit Reload. Now, start a new email, press G, then M, then TAB. Good Morning will magically appear. The G M is called a Hotstring. Your script file can include as many of these as you like. To keep them organized, I suggest an extra line return between them..

::gm:: 
Send Good Morning
return

::ty:: 
Send Thank You
return

but, back to GM.. 

::gm::
Send Good Morning
return

Ok, lets quickly go over each line. The first defines what keys you're pressing. If the string is between ::'s ( ie.. ::gm:: ), AutoHotkey recognizes it as a Hotstring - the routine will run if those keys are pressed. *Note that until you press TAB or SPACEBAR after the Hotstring itself, the program assumes you are typing a longer word, by pressing TAB or SPACEBAR, the program knows to run the routine. The second line shows the first command to trigger. "Send" is one of the most useful commands, literally telling AutoHotkey to SEND the keys following it on that line to the computer. If you changed the Good Morning in the code above to I Like Turtles, it would automatically type I Like Turtles. To tell AutoHotkey to send non-character keys, you'll have to learn their labels - {SHIFT}, {ENTER}, etc.. you can look at the Help file or the AutoHotkey website for key name lists & other commands. The Return on the final line signals the program to stop running the current routine (and not run any further code).

So, as you can see, its very easy to get started. If this is as far as you go, hopefully you can put this little hack to work for you. Even just learning the power of Hotstrings can eliminate a great deal of needless typing.

I will go into more advanced AutoHotkey scripting, as well as some clever ways to manage information with it, in future posts.

Thanks for reading!

Sort:  

Upvoted you

Coin Marketplace

STEEM 0.21
TRX 0.14
JST 0.030
BTC 69812.20
ETH 3376.99
USDT 1.00
SBD 2.78