Advertisement

What is AutoHotkey? Start using it with basic examples

-
3 years ago

You're not happy with keyboard shortcuts of your favorite program? Then, AutoHotkey is for you. It allows to automate many things with keyboard shortcuts.

AutoHotkey works with scripts and may look daunting at first, but it's easier once you get your hands into it. It's true AutoHotkey has its own scripting syntax which you'll need to learn, but it gives you ability to do many things from remapping existing keys to create simple hotkeys just in a few lines.

Note: As AutoHotkey automates key presses, using it with multiplayer games may cause you to be flagged as a cheater.

Installing and using AutoHotkey

After downloading and installing AutoHotkey, you need to create or use an existing script. This is how a script looks like:

; Run the Character Map
^+5::Run charmap.exe
return

First line is a comment and does nothing other than explaining code to the user. Second line means when you press Ctrl (^) Shift (+) 5 the Character Map application will run. Third line just says the AutoHotKey script ended.

This is how you run this script:

  • Right click in a folder or desktop and click New > AutoHotkey Script.
  • Give the new file a name, be careful to not change .ahk extension.
  • To open the file for editing, right click on it and select Edit script.
  • Copy and paste the above code to the end of the script, then save it.
  • When you double-click the script, it'll run.

When script is running, you'll see a "H" icon in the system tray and it'll be active until you close it by right clicking and clicking Exit. 

If you wanted this shortcut (Ctrl + Shift + 5) to not run when WordPad is open, the code would look like this:

SetTitleMatchMode, 2

#IfWinNotActive WordPad
; Run the Character Map
^+5::Run charmap.exe
return
#IfWinNotActive

With SetTitleMatchMode 2, we tell AutoHotkey to match window title if it contains the title string we'll provide. #IfWinNotActive WordPad is obvious, it means only execute the code if active window doesn't contain "Wordpad" in its title.

At that point, you may be telling yourself "I'm not trying to be a programmer" and/or "I don't want to take time fiddling with this stuff". You may choose not to, but keep in mind there are many AutoHotkey scripts available on the web for various tasks. For example, this script minimizes any active window to system tray with a keyboard shortcut, while this one converts your joystick to a three-button mouse

Also, the guide provided by AutoHotkey is quite clear for beginners and also comprehensive for more experienced script writers.

Did you find this article useful?
2 0
Share this page on:



 

Guest OP says : 3 years ago 7/16/2021 8:23 AM
Nice article. Thank you for sharing.
Power BI Training
DevOps Online Training

Apoorva OP says : 3 years ago 7/1/2021 8:50 AM
Thanks for sharing info.
machine learning online course