Send Key

Sends keystrokes to the system.

Command availability: IBM RPA SaaS and IBM RPA on premises

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

sendKeys --keys(String) [--viacurrentwindow(Boolean)] [--legacy(Boolean)] --mode(Nullable<ScanMode>) [--ignorespecialcharacters(Boolean)] [--disablecapslock(Boolean)]

Dependencies

If your bot is interacting with an application, make sure the application's window is in focus before using a keyboard command. Use one of the following commands to put a window in focus:

Input parameter

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Keys keys Required Text Keystrokes that should be sent to the system.

Note:To learn more about sending keystrokes to an application, refer to Send Keys 🡥
Via Current Window viacurrentwindow Optional Boolean Enable to send keystrokes to the current window.
Use Legacy Input Mode legacy Optional Boolean Enabled to send keystrokes in legacy mode.
Legacy Input Mode mode Required when the Use Legacy Input Mode parameter is enabled ScanMode Legacy mode used to send keystrokes.

See the mode parameter options
Ignore Special Characters ignorespecialcharacters Optional Boolean Enabled to ignore the sending of special characters.
Disable Capslock disablecapslock Optional Boolean Enable to disable Caps Lock when sending keystrokes.

mode parameter options

The following table displays the options available for the mode input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.

Designer mode label Script mode name Description
V1 v1 Matches the version 1 of legacy input mode.
V2 v2 Matches the version 2 of legacy input mode.

Example

Example 1: The Launch and Attach Window (launchWindow) command opens the Notepad application, with the Focus Window (focusWindow) command putting it in the foreground, and the Send Key command sends the characters "i", "b" and "m" for that application, resulting in "ibm".

defVar --name notepadWindow --type Window
launchWindow --executablepath "notepad.exe" notepadWindow=value
// Put the Notepad in the foreground.
focusWindow --window ${notepadWindow}
sendKeys --keys ibm
// Send the "ibm" keys to Notepad.

Example 2: The Launch and Attach Window (launchWindow) command opens the Notepad application, with the Focus Window (focusWindow) command putting it in the foreground. The Click (click) command clicks this application and the Send Key command sends the Enter key, resulting in a line break in the open Notepad.

defVar --name notepadWindow --type Window
// It opens the notepad.
launchWindow --executablepath "notepad.exe" notepadWindow=value
// Put the Notepad in the foreground.
focusWindow --window ${notepadWindow}
// Click on Notepad.
click --selector "Id" --controlsimilarity 100 --id 15
// Type the "ENTER" key.
sendKeys --keys "{ENTER}" --viacurrentwindow