Post

Mastering AutoHotkey (AHK): A Beginner's Guide to Automation With a Video

Video 📺

📺 Watch here

Introduction

Ever wished you could automate repetitive tasks on your computer? Whether it’s fixing typos, launching apps with a keystroke, or creating powerful macros, AutoHotkey (AHK) is the perfect tool. It’s lightweight, powerful, and easy to learn. In this guide, we’ll explore the basics of AHK syntax and help you get started with simple yet effective scripts.

What is AutoHotkey? 👀

AutoHotkey is a free scripting language for Windows that lets you automate tasks using hotkeys, macros, and text expansion. You can:

  • Remap keys and mouse buttons
  • Create text shortcuts
  • Automate repetitive tasks
  • Control windows and applications

Getting Started

To use AutoHotkey, download and install it from https://www.autohotkey.com/. Once installed, create a new .ahk file, open it in a text editor, and start scripting!


1. Creating Hotkeys

Hotkeys allow you to execute actions with a simple key combination. Here’s how you create one:

; This script opens Notepad when you press Win + N ; #n::Run Notepad

Explanation:

  • # represents the Windows key.
  • n is the key to trigger the action.
  • :: separates the key from the action.
  • Run Notepad launches Notepad.

Other Modifier Keys:

SymbolKey
^Ctrl
!Alt
+Shift
#Windows

Example: Open Calculator with Ctrl + Alt + C:

^!c::Run Calc

2. AutoCorrect and Text Expansion

AHK is fantastic for fixing typos automatically or expanding shortcuts into full text.

::teh::the ::brb::Be right back ::omw::On my way!

Now, every time you type teh, AHK will automatically replace it with the.


3. Remapping Keys

If you want to swap keys or disable them, AHK makes it easy.

`CapsLock::Ctrl ; Turn Caps Lock into a Ctrl key.` `Esc::F7 ; Make Escape key type a F7`

4. Sending Keystrokes

You can simulate typing and shortcuts using the Send command.

`^t::Send, Hello, this is an AutoHotkey script!`

This sends the text when you press Ctrl + T.


5. Running Programs and Opening Websites

Quickly open apps or websites with hotkeys:

#b::Run https://www.bing.com

6. Creating Message Boxes

Display a popup message:

F2::MsgBox, Hello! This is an AutoHotkey message box.

7. Using Loops for Automation

Automate repetitive tasks with loops.

F3:: Loop 5 { Send, Hello!{Enter} Sleep, 1000 ; Wait 1 second } return

Press F3, and it will type “Hello!” five times, pausing for one second between each.


Conclusion

AutoHotkey is an incredible tool that can supercharge your workflow. This guide just scratches the surface. Experiment with these scripts, tweak them, and soon you’ll be automating your tasks like a pro!

GUI for download 🌻🌼

you can download a GUI i created in my Ko-Fi link below~

its free or you can leave tip if you find this tool useful for you 😃 enjoy!

☕ Ko-Fi: DOWNLOAD HERE

Happy scripting! 🚀

This post is licensed under CC BY 4.0 by the author.