Places a message in the message queue of a window or control.

PostMessage Msg , wParam, lParam, Control, WinTitle, WinText, ExcludeTitle, ExcludeText



Type: Integer

The message number to send. See the message list to determine the number.

wParam, lParam

Type: Integer

The message parameters. If omitted, each parameter defaults to 0.

Each parameter must be an integer.

If AutoHotkey or the target window is 32-bit, only the parameter's low 32 bits are used; that is, values are truncated if outside the range -2147483648 to 2147483647 (-0x80000000 to 0x7FFFFFFF) for signed values, or 0 to 4294967295 (0xFFFFFFFF) for unsigned values. If AutoHotkey and the target window are both 64-bit, any integer value supported by AutoHotkey can be used.


Type: String, Integer or Object

If this parameter is omitted, the message will be posted directly to the target window rather than one of its controls. Otherwise, this parameter can be the control's ClassNN, text or HWND, or an object with a Hwnd property. For details, see The Control Parameter.

If this parameter specifies a HWND (as an integer or object), it is not required to be the HWND of a control (child window). That is, it can also be the HWND of a top-level window.


Type: String, Integer or Object

A window title or other criteria identifying the target window. See WinTitle.


Type: String

If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.


Type: String

Windows whose titles include this value will not be considered.


Type: String

Windows whose text include this value will not be considered.

Error Handling

A TargetError is thrown if the window or control could not be found.

An OSError is thrown if the message could not be posted. For example, if the target window is running at a higher integrity level than the script (i.e. it is running as admin while the script is not), messages may be blocked.


This function should be used with caution because sending a message to the wrong window (or sending an invalid message) might cause unexpected behavior or even crash the target application. This is because most applications are not designed to expect certain types of messages from external sources.

PostMessage places the message in the message queue associated with the target window. It does not wait for acknowledgement or reply. By contrast, SendMessage waits for the target window to process the message, up until the timeout period expires.

Unlike SendMessage, PostMessage usually only sends basic numeric values, not pointers to structures or strings.

To send a message to all windows in the system, including those that are hidden or disabled, specify 0xFFFF for WinTitle (0xFFFF is HWND_BROADCAST). This technique should be used only for messages intended to be broadcast.

To have a script receive a message, use OnMessage.

See the Message Tutorial for an introduction to using this function.

Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.

SendMessage, Message List, Message Tutorial, OnMessage, Automating Winamp, DllCall, ControlSend, MenuSelect


Switches the active window's keyboard layout/language to English (US).

PostMessage 0x0050, 0, 0x4090409,, "A"  ; 0x0050 is WM_INPUTLANGCHANGEREQUEST.