Share via


Keyboard.SendKeys Method (UITestControl, String, Boolean)

Sends keystrokes to generate the specified text string.

Namespace:  Microsoft.VisualStudio.TestTools.UITesting
Assembly:  Microsoft.VisualStudio.TestTools.UITesting (in Microsoft.VisualStudio.TestTools.UITesting.dll)

Syntax

'Declaration
Public Shared Sub SendKeys ( _
    control As UITestControl, _
    text As String, _
    isEncoded As Boolean _
)
public static void SendKeys(
    UITestControl control,
    string text,
    bool isEncoded
)
public:
static void SendKeys(
    UITestControl^ control, 
    String^ text, 
    bool isEncoded
)
static member SendKeys : 
        control:UITestControl * 
        text:string * 
        isEncoded:bool -> unit 
public static function SendKeys(
    control : UITestControl, 
    text : String, 
    isEncoded : boolean
)

Parameters

  • text
    Type: System.String
    The text for which to generate keystrokes.
  • isEncoded
    Type: System.Boolean
    true if the text is encoded; otherwise, false.

Remarks

The string may contain key modifiers.

  • Control
    ^

  • Shift
    +

  • Alt
    %

  • Windows
    #

To send a Control+A keyboard sequence, use SendKeys("^a").

To send a character that represents a key modifier, enclose the character in a pair of braces. For example, to send a plus sign, use SendKeys("{+}").

To send a brace, enclose the brace in a pair of braces. For example, to send an opening or closing brace, use SendKeys("{{}") or SendKeys("{}}"), respectively.

.NET Framework Security

See Also

Reference

Keyboard Class

SendKeys Overload

Microsoft.VisualStudio.TestTools.UITesting Namespace