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.
⚠️ Always include an emergency stop such as Esc::ExitApp in any script that sends keys or clicks in a loop. A loop typing into the wrong window can do real damage.
💡 Prefer keyboard navigation (Tab, arrows, shortcuts) over mouse coordinates; it keeps working when windows move or screen resolution changes.
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.