Write AutoHotkey v2 scripts for window targeting, hotkeys, and GUI automation

domain: autohotkey.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. 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.
  2. 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.
  3. Send keystrokes to the active window with `Send('{Enter}')` or `SendText('hello world')` for literal text that should not be interpreted as special keys.
  4. 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.
  5. 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

Related routes

Automate Windows desktop GUI applications with AutoHotkey v2 using hotkeys and control interactions
autohotkey.com · 6 steps · unrated
Migrate an AutoHotkey v1 script to v2 syntax without breaking hotkeys and functions
autohotkey.com · 6 steps · unrated
Control Microsoft Office applications from AutoHotkey v2 using ComObject and ComObjActive
desktop-automation · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans