Skip to main content

Robot Task Activities - Keyboard​

The Keyboard activities send key presses and key events to the window that has focus.

The Keyboard category in the activity list, with Key Event and Press Key


Key Event​

Sends one key event: the key goes down or comes up.

The Key event activity with the Key and Status fields

  • Key: the key to send, chosen from the list, for example "Control", "Shift" or "A". Default: "None"
  • Status: the key state to send: "Down" or "Up". Default: "Down"

Use Key Event to hold a key down across other activities: send "Down", run the activities, then send "Up" for the same key to release it.


Press Key​

Presses one key or several keys, either one after another or together as a combination.

The Press Key activity with the Keys field, the ... button and the Is combination check box

  • Keys: the names of the keys to press, separated by commas, for example Control,C. Default: "None"
  • Is combination: when checked, the keys are pressed together. When cleared, they are pressed one after another, in order. Default: cleared
  • KeyPressDelay: in the Properties pane, the wait in milliseconds before each key when the keys are pressed one after another. Default: "100"

With Control,C and Is combination checked, the activity sends Ctrl+C. With Is combination cleared, it presses Control and then C as two separate keys.

Selecting keys

Click the ... button to open the virtual keyboard and choose the keys there instead of typing their names.

The virtual keyboard window, with a button for each key

Click Detect to capture keys from the physical keyboard. In the Press any key to detect window, press the keys, then click Set to fill in Keys, or Clear to start again.

The Press any key to detect window, with the detected key names and the Clear and Set buttons

If a name in Keys is not a known key name, the activity fails without pressing any key. When Keys is empty, the activity presses no key and does not fail.


Tips​

  • Keyboard activities send input to the window that has focus. Before sending keys, give the target window focus with a Windows activity such as Attach Window with SetFocus checked, or with the Controls Set Focus activity
  • To type text into a field, use the Text Send Text activity rather than a chain of Press Key activities. Send Text can also find a specific element and decide what happens to existing text
  • Use Detect or the virtual keyboard rather than typing key names. The names they fill in are names the activity accepts
  • Increase KeyPressDelay if an application misses keys. Some applications cannot keep up with input sent at full speed