Keyboard.SendKeys 方法 (UITestControl, String)

发送击键以生成指定的文本字符串。

命名空间:  Microsoft.VisualStudio.TestTools.UITesting
程序集:  Microsoft.VisualStudio.TestTools.UITesting(在 Microsoft.VisualStudio.TestTools.UITesting.dll 中)

语法

声明
Public Shared Sub SendKeys ( _
    control As UITestControl, _
    text As String _
)
public static void SendKeys(
    UITestControl control,
    string text
)
public:
static void SendKeys(
    UITestControl^ control, 
    String^ text
)
static member SendKeys : 
        control:UITestControl * 
        text:string -> unit 
public static function SendKeys(
    control : UITestControl, 
    text : String
)

参数

备注

该字符串可以包含键修饰符。

  • 控件
    ^

  • Shift
    +

  • Alt
    %

  • Windows
    #

若要发送 Ctrl+A 按键顺序,请使用 SendKeys("^a")。

若要发送一个表示密钥修饰符的字符,请将该字符用一对大括号括起来。 例如,要发送加号,请使用 SendKeys("{+}")。

若要发送括号,请将括号用一对花括号括起来。 例如,要发送左或右括号,请分别使用 SendKeys("{{}") 或 SendKeys("{}}")。

.NET Framework 安全性

请参见

参考

Keyboard 类

SendKeys 重载

Microsoft.VisualStudio.TestTools.UITesting 命名空间