How To Guides Org

Learning Autohotkey Part 1: What Is AutoHotkey And How To Automate Repetitive Tasks

In this guide we’ll explain how to install AutoHotkey and create your first script

What is AutoHotkey

Every modern web browser will “remember” your email, Tweeter, and Facebook passwords and credentials, but when it comes to automating repetitive tasks, you would need something much more robust than a browser.

This is where AutoHotkey comes in – AutoHotkey is a freeware scripting language, which is surprisingly easy to learn and can help you create hotkeys and macros, re-map the keys on your keyboard, launch executable programs, and much more. If you find yourself typing in the same text over and over or performing the same sequence of mouse clicks often, you can make your life so much easier by creating one or more simple AutoHotkey scripts.

Installing AutoHotkey and creating your first script

1. Step Installing AutoHotkey – before you begin, you need to download the program and install it on your computer. Once this is out of the way, you can create your first script in Notepad. Note that the AutoHotkeys scripts need to have .ahk extension in order to be recognized and executed by AutoHotkeys.exe.

Let’s start creating our first AutoHotkey script.

2. Step Writing the simple script – once you have AutoHotkey installed, open Notepad and paste the following text:

z & i::
Run, Notepad.exe
Sleep, 3000
Clipboard = Hello World
Send ^v
return

3. Step Saving the script – save the file as script.ahk (not as script.txt) in a folder of your choice. Double click the script.

4. Step Running and testing the script – make sure that the script is running – you should see a small square icon with the letter H in the Notifications Area of your taskbar. Now, hold down the “z” key on your keyboard, press the “i” key and release them both. In a second, the script should launch Notepad and three seconds later, it should paste the text “Hello World” in the open Notepad window.

5. Step Understanding the AutoHotkey script. Let’s go over the script step by step. The first line is “z & i::”

This is the hotkey that we are creating – once you have the script running, each time you hold down the “z” key and press the “i” on your keyboard, the script will execute one or more actions, every line that we put between “z & i::” and “return.”

The second line is “Run, Notepad.exe” and this is the line that launches Notepad. If this line fails to execute when launching programs, specifying the program path will easily resolve this.

The next line in our first AutoHotkey script is “Sleep, 3000” – this tells the script to “sleep” 3000 milliseconds (3 seconds) before executing the following line, “Clipboard = Hello World.” “Clipboard = Hello World” places the text “Hello World” in your computer’s clipboard, and the last line before “return,” “Send ^v” simulates the “Ctrl + v” ley function, which pastes the text in Notepad. The simple script that we have created might not seem that impressive, but you can use AutoHotkey to automate far more complex tasks, compile the scripts into executable files, distribute and run them on other computers, and more – visit the official AutoHotkey to learn more about the program and its capabilities.

Computer Programming For Beginners

Unlike computer programming, AutoHotkey doesn’t require years of practice and you can start writing your own scripts right away using NotePad or your favorite text editor. Once you learn the basics, you can then move on to building more complex scripts and learn some of the advanced features such as using variables and objects, error handling, data types, and other.