Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Windows.Forms SendKeys escape keywords

Tags:

c#

sendkeys

I'm attempting to send the { key using SendKeys.SendWait(y). I'm passing a variable, y in this case, that has been set with a string containing {.

string y = "u8HXV/gIE_{";
SendKeys.SendWait(y);
SendKeys.SendWait("{TAB}");
SendKeys.SendWait("{ENTER}");

I'm getting the following error:

An exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll 
but was not handled in user code
Additional information: Keyword delimiter is missing.

Is there a way of escaping this keyword { within SendKeys?

like image 899
JAdam Avatar asked Aug 30 '26 18:08

JAdam


1 Answers

The curly brace is a special symbol for the SendKeys method, so you need to escape it (treat it like special symbol) like this:

SendKeys.SendWait("{{}");

The output is: {

like image 132
keenthinker Avatar answered Sep 02 '26 07:09

keenthinker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!