简体   繁体   English

Vb.net将组合键发送到Windows应用

[英]Vb.net send key combo to windows app

I would like to send Shift + Ctrl + + to my VB.Net WinForms application. 我想将Shift + Ctrl + +发送到我的VB.Net WinForms应用程序。 My code below does not work. 我下面的代码不起作用。 Please help: 请帮忙:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    SendKeys.Send("^+({ADD})")
End Sub

According to the documentation , + should be represented as {+} . 根据文档+应该表示为{+}

In addition, as I read the documentation, you can combine Shift , Ctrl and Alt for a single key without needing to encompass each key in parentheses. 另外,在阅读文档时,您可以将ShiftCtrlAlt组合为单个键,而不必在括号中包含每个键。 You only need parentheses if combining these modifier keys with multiple keys. 如果将这些修饰键与多个键组合使用,则仅需要括号。

To specify keys combined with any combination of the SHIFT, CTRL, and ALT keys , precede the key code with one or more of the following codes. 要指定与SHIFT,CTRL和ALT键的任意组合结合的键 ,请在键代码之前加上以下一个或多个代码。

For example, if you wanted to press and hold Ctrl and Alt while pressing A and then B , you'd use ^+(AB) . 例如,如果要在按住AB的同时按住CtrlAlt ,则可以使用^+(AB)
( ^+AB would produce Ctrl + Alt + A , then release the modifier keys and press B .) ^+AB将产生Ctrl + Alt + A ,然后释放修饰键并按B。

Since you only want to press + , I believe the following should work: 由于您只想按+ ,所以我相信以下方法应该起作用:

SendKeys.Send("^+{+}")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM