Skip to content

AutoHotkey

Claude edited this page Jun 30, 2026 · 1 revision

AutoHotkey Add-in (Windows)

AutoHotkey (AHK) is a powerful complement: its ControlSend/ControlClick drive background windows very reliably (better than raw PostMessage for many apps), and run_ahk is a full scripting escape hatch.

Install

winget install -e --id AutoHotkey.AutoHotkey

The server auto-detects AHK on PATH, in common install dirs, or via the LOWLEVEL_CU_AHK environment variable (set it to an AutoHotkey*.exe path to pin a specific interpreter). Generated helpers target AHK v2; run_ahk runs whatever interpreter is found.

Check it's found

ahk_status {}

{installed, path, version} or {installed:false, hint}.

Send background input

Send text to a window by HWND (no focus needed):

ahk_control_send { "text": "hello", "window": "ahk_id 0x1A2B3C" }

Target by process or title instead:

ahk_control_send { "text": "hello", "window": "ahk_exe notepad.exe" }

Send key syntax instead of literal text (as_keys):

ahk_control_send { "text": "^a{Del}", "window": "ahk_exe notepad.exe", "as_keys": true }
  • window is an AHK target string: "ahk_id <hwnd>", "ahk_exe <exe>", or a title.
  • control (optional) targets a specific control; blank = the window's focused control.

Run arbitrary AHK

The script must terminate (call ExitApp, or be non-persistent) or it runs until the timeout. Emit stdout with FileAppend ..., "*".

run_ahk { "code": "ControlSendText \"hi\", , \"ahk_exe notepad.exe\"\nExitApp" }

Parameters: code, args (passed to the script), timeout (default 60), exe_path (override interpreter). Returns {returncode, stdout, stderr, exe}.

When to use AHK vs the built-in tools

Use AHK when an app ignores Win32 PostMessage/WM_CHAR (see the limitations in Background Targeting). ControlSend works for many such apps. For everything else, the built-in win_set_control_text / background type_text are simpler.

Clone this wiki locally