Click or drag to resize
Ranorex

KeyboardPress Method (Element, String, Duration)

Presses the keys specified by sequence.

Namespace:  Ranorex
Assembly:  Ranorex.Core (in Ranorex.Core.dll) Version: 12.7.4-git.38314c06
Syntax
public static void Press(
	Element focusTarget,
	string sequence,
	Duration keyPressTime
)

Parameters

focusTarget
Type: Ranorex.CoreElement
The element to set the focus to, if possible, before entering the sequence.
sequence
Type: SystemString
A sequence of characters and escape groups that specify the keys to press.
keyPressTime
Type: RanorexDuration
The key press time.
Remarks
Each key is repesented by a single character or an escape group. To specify a single keyboard character, use the character itself (e.g. use "aBc" to press the keys A, B+Shift, and C after another). Only the '{' character has a special meaning and needs to be escaped by preceding it with another '{' (specify "{{" to issue a '{' key press).

Escape groups, signalled by braces "{}", may be used to produce a key action with any of the keys specified by the Keys enumeration. "{Z}" means that the 'z' key should be pressed, and "{return}" or "{enter}" that the Return key is to be pressed.

Additionally, in an escape group you can specify a modifier that determines whether the key should be hold down (e.g. {CONTROL down}), released (e.g. {shift up}), or pressed a number of times (e.g. {z 3}). In an escape group, key name and modifier must be separated by a single shift character.

The keys A to Z set the key modifiers (ALT, CTRL, SHIFT) and in particular the shift key depending on their case, even if used in an escape group. If these keys should not modify the shift key state, wrap them into an escape group and add "key" to the character, e.g. "{Rkey}" to press the R key without changing the shift key state.

See Also