How to Write Your First AutoHotkey Script Today AutoHotkey (AHK) is a powerful, free, open-source scripting language for Windows. It allows you to automate repetitive tasks, create custom keyboard shortcuts, and boost your daily productivity.
Writing your first script takes less than five minutes. Here is how to get started today. Step 1: Install AutoHotkey
Before writing code, you need to install the software that interprets your scripts. Go to the official AutoHotkey website.
Download the current stable version (AutoHotkey v2 is highly recommended as it is the modern standard).
Run the installer and follow the standard on-screen prompts. Step 2: Create Your First Script File
AutoHotkey scripts are just plain text files with a specific file extension.
Right-click on an empty space on your desktop or inside any folder.
Hover over New and select AutoHotkey Script (or select Text Document if the option is missing).
Name your file MyFirstScript.ahk. Ensure the extension is .ahk and not .txt. Step 3: Write the Code
Let’s create a “hotstring” (a text expansion shortcut) and a “hotkey” (a keyboard shortcut).
Right-click your new MyFirstScript.ahk file and select Edit Script (or open it with Notepad). Delete any default text that appears. Paste the following three lines of code: autohotkey
#Requires AutoHotkey v2.0 ::btw::by the way ^j::MsgBox “Hello, World!” Use code with caution. Code Breakdown
#Requires AutoHotkey v2.0: Tells the system to run this script using version 2.
::btw::by the way: This is a hotstring. Whenever you type “btw” followed by a space or punctuation, it instantly expands to “by the way”.
^j::MsgBox “Hello, World!”: This is a hotkey. The ^ symbol represents the Ctrl key. Pressing Ctrl + J triggers a pop-up window that says “Hello, World!”. Step 4: Run the Script Save the file and close your text editor. Double-click the MyFirstScript.ahk file.
Look at your Windows system tray (bottom right corner of your taskbar). You will see a green “H” icon, indicating your script is running in the background. Step 5: Test It Out
Open Notepad, a web browser, or any text field to test your creation: Type btw and hit the Spacebar. Watch it expand.
Press Ctrl + J on your keyboard. Your custom pop-up message will appear. Tips for Modifying Your Scripts To edit: Right-click the file -> Edit Script.
To apply changes: After saving edits, right-click the green “H” icon in the system tray and click Reload This Script. To stop: Right-click the green “H” icon and click Exit.
Congratulations! You just automated your first digital task. You can now add more shortcuts to this file to build your ultimate productivity tool. If you want to customize this script further, tell me: What repetitive typing task you want to automate
What custom keyboard shortcuts you would like to createI will write the exact v2 code for you. Saved time Comprehensive Inappropriate Not working
A copy of this chat, including the images and video, will be included with your feedback A copy of this chat will be included with your feedback
Your feedback will include a copy of this chat and the image from your search
Your feedback will include a copy of this chat, any links you shared, and the image from your search.
Thanks for letting us know
Google may use account and system data to understand your feedback and improve our services, subject to our Privacy Policy and Terms of Service. For legal issues, make a legal removal request.