Click here to Skip to main content
15,921,660 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
How to send special characters by SendKeys.SendWait() method ?

I am sending this url
"https://www.google.com/search?client=firefox-b-d&q=%3A}O"
by
C#
SendKeys.SendWait(txt)
method but error displays

System.ArgumentException: 'SendKeys string 'https://www.google.com/search{?}client=firefox{-}b{-}d{&}q={%}3A}O' is not valid.'


What I have tried:

I have tried this regex but url becomes useless.

Regex specialChar = new Regex(@"^[a-zA-Z0-9_@.-]*$");


Any help please
Posted
Updated 17-Dec-22 21:27pm
v2

1 solution

You have a number of normal characters in your string surrounded by braces ({ and }). These are not valid special types. See SendKeys.Send(String) Method (System.Windows.Forms) | Microsoft Learn[^] for the full list.
 
Share this answer
 
Comments
DoingWork 19-Dec-22 0:43am    
Thanks for your guidance. I had already read this article, but on again reading, I have come to know that I was missing something. I just also put } character in between { and } then my problem has been solved.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900