Target a specific window using `WinActivate` with a title or class: `WinActivate('Untitled - Notepad')` or `WinActivate('ahk_class Notepad')` — use the bundled Window Spy utility to find the exact window title and class.
Define a hotkey with the `::` syntax: `^!n::` followed by the script body and `return` (or use a function hotkey `^!n:: MyFunc()`) — `^` is Ctrl, `!` is Alt, `+` is Shift, `#` is Win.
Send keystrokes to the active window with `Send('{Enter}')` or `SendText('hello world')` for literal text that should not be interpreted as special keys.
Click UI elements by position or use `ControlClick` to click a named control without activating the window: `ControlClick('Button1', 'ahk_class MyApp')` targets the control by its class number.
Use `WinWaitActive('Window Title')` before interacting to block until the target window becomes active, preventing race conditions when automating sequences that open new windows.
Known gotchas
AutoHotkey v2 is not backward compatible with v1 scripts — the syntax for many constructs (functions, objects, class definitions, legacy commands) changed significantly. Scripts written for v1 will not run in v2 without modification; check which version you are targeting before copying examples from the web.
`Send` has several variants (`Send`, `SendInput`, `SendEvent`, `SendPlay`) with different underlying mechanisms and compatibility with different applications. Games and applications that use low-level input hooks may not respond to `SendInput`; try `SendPlay` or `ControlSend` as alternatives.
Window titles are matched as substrings by default (`SetTitleMatchMode 2`). A script that targets 'Notepad' may accidentally activate a window whose title contains the word 'Notepad' as a substring (e.g., 'Super Notepad Pro'). Use the full window title or `ahk_class` to be more precise.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp