
📎 This article includes 1 downloadable practice file ↓
AHK can type and click for you: filling repetitive forms, moving through rows, entering standard values. Done carelessly, it types into the wrong window. Here’s how to do it safely.
Send vs SendText
Send "{Down}{Enter}" sends keys (braces for special keys; ^ ! + # mean modifiers). SendText "50% off!" types text literally, so symbols aren’t treated as modifiers.
Pace and wait
SetKeyDelay 50 ; 50 ms between keys
WinWaitActive "ahk_exe EXCEL.EXE",, 5 ; wait up to 5 s for Excel
Sleep 150 ; small pause for slow apps
Mouse
Click 200, 340 clicks at a position. Set CoordMode "Mouse", "Window" so positions are relative to the window, not the screen, and use Window Spy to read them.
Where people go wrong
| Problem | Fix |
|---|---|
| Keys typed into another window | WinWaitActive before sending |
| Missed keystrokes | SetKeyDelay / Sleep |
| Script can’t be stopped | Esc::ExitApp |
Practice
Open a blank Excel sheet, click A1, run the script and press F8. Press Esc to stop at any time.
📎 Practice files for this article
- ⌨️Lesson 4 script (AutoHotkey v2)Double-click to run after installing AutoHotkey v2.⬇ AHK · 313 B
Free to use for learning. Files with macros (.bas) are plain text — import them with Alt+F11 → File → Import File, and always test on a copy.
Stuck on a step? Ask a question and the AI answers using this article.