3
votes

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
{RSHIFT}+ should work right?kevintjuh93
@kevintjuh93 {RSHIFT} throws Keyword "RSHIFT" is not valid.Alex Jolig
That is weird, according to several sources it should work. Anyway, you are probably going to need PostMessage now. Can you also tell me why you need to send these keys to your RTB?kevintjuh93
@kevintjuh93 Because RichTextBox doesnt support text direction. it only has RightToLeft which doesn't work well for RightToLeft languagesAlex Jolig
Where are you placing this code?kevintjuh93

1 Answers

0
votes

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}+)")