Simulate right Shift+Ctrl with SendKeys.Send()

我怕爱的太早我们不能终老 提交于 2019-12-23 15:35:58

问题


I'm trying to Send right Shift+Ctrl to my RichTextBox. But as default it sends the left keys.

SendKeys.Send("^+");

Is there anyway to simulate right Shift+Ctrl?


回答1:


Yes you can, you can check the Virtual-Key Codes where the code for the right shift key and right control key is

VK_RSHIFT   0xA1
VK_RCONTROL 0xA3

So you can do like

public const int VK_RSHIFT  = 0xA1;
public const int VK_RCONTROL= 0xA3;

or

You can try like this:

SendKeys.Send(VirtualKeyCode.VK_RSHIFT);

or else you can use the Keys Enumeration

Specifies key codes and modifiers.

which specifies

RShiftKey for the right shift key and RControlKey for the right control key.

or as commented by kevintjuh93

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


来源:https://stackoverflow.com/questions/33118603/simulate-right-shiftctrl-with-sendkeys-send

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!