Function Reference
ControlSend
Sends a string of characters to a control.
Parameters
| title |
The title of the window to access. |
| text |
The text of the window to access. |
| controlID |
The control to interact with. See Controls. |
| string |
String of characters to send to the control. |
| flag |
[optional] Changes how "keys" is processed:
flag = 0 (default), Text contains special characters like + to indicate SHIFT and {LEFT} to indicate left arrow.
flag = 1, keys are sent raw. |
Return Value
| Success: |
Returns 1. |
| Failure: |
Returns 0 if window/control is not found. |
Remarks
ControlSend works in a similar way to Send but it can send key strokes directly to a window/control, rather than just to the active window.
ControlSend is only unreliable for command prompts as that works differently to normal windows (seems to check physical states rather than accepting the keystroke messages). For normal windows ControlSend should be way more reliable than a normal Send - and yes it does send shift, ctrl, alt etc.
As mention in the Send help the keyboard that send different chars when in CAPS LOCK and using the Shift Key cannot be simulated. An example is the Czech Keyboard. A good workaround is to use the ControlSetText.
The control might first need to be given focus with the ControlFocus command, specially when referencing an controlID created by the script itself.
Opt("SendKeyDelay",...) alters the length of the brief pause in between sent keystrokes.
Opt("SendKeyDownDelay",...) alters the length of time a key is held down before being released during a keystroke.
Related
ControlCommand, Send, ControlSetText, ControlFocus, SendKeyDelay (Option), SendKeyDownDelay (Option)
Example
ControlSend("[CLASS:Notepad]", "", "Edit1", "This is a line of text in the notepad window")