2
votes

AutoHotkey's official documentation lists two different sets of commands for sending simulated keyboard input to a window.

Send / SendRaw / SendInput / SendPlay / SendEvent

Sends simulated keystrokes and mouse clicks to the active window.

ControlSend / ControlSendRaw

Sends simulated keystrokes to a window or control.


  • What's the difference between Send and ControlSend?
  • Is there a reason to use one over the other?
1

1 Answers

4
votes

Send/SendXXX commands send input to the active window. That is the window that currently has focus, usually by clicking it with your mouse, tabbing to it, or when a window sets focus to itself.

If your AHK script were to target a Notepad window that you have open, and you were to click on another window such as Chrome, your inputs would now be sent to Chrome.

On the flipside, using ControlSend/ControlSendXXX commands will send input to a specified window or control. A control might be a textbox, button, or similar interactive elements.

Here, the above example would still output to Notepad even if you switched focus to another window such as Chrome. The downside is that you must specify which control to send to.