I am writing an app which uses SendKeys
to send text at the cursor whenever text is available. Each time the app has to write the percentage sign, it writes number 5 instead. I send 10{%}
and my output is 105
. I can't figure how to simply make the %
symbol appear.
From MSDN :
The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses () have special meanings to SendKeys. To specify one of these characters, enclose it within braces ({}). For example, to specify the plus sign, use "{+}". To specify brace characters, use "{{}" and "{}}".
Here is a really simple sample to reproduce the issue (ConsoleApp with System.Windows.Forms reference)
namespace ConsoleApp4
{
class Program
{
static void Main(string[] args)
{
System.Threading.Thread.Sleep(1000);
string text = "10{%}";
// Output SHOULD be "10%"
// Output IS "105"
System.Windows.Forms.SendKeys.SendWait(text);
Console.ReadLine();
}
}
}
Output is 105
instead of 10%
.
I can't figure this out, how can I write %
symbol using SendKeys ?