Stevoisiak
Stevoisiak

Reputation: 26862

What's the difference between Send and ControlSend?

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.


Upvotes: 3

Views: 4000

Answers (1)

user820304
user820304

Reputation:

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.

Upvotes: 5

Related Questions