I am running on an issue using C# SendKeys.Send method. I am trying to replace keyboard keys with other keys, for example when I press \"a\" in keyboard I want that key to b
I might be making a bad assumption, but if you are using this with a text box, you could:
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 'a')
{
e.Handled = true;
}
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.A)
{
e.Handled = true;
SendKeys.Send("s");
}
}
Or even simpler:
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 'a')
{
e.Handled = true;
SendKeys.Send("s");
}
}
Or if this isn't for use just with a text box, then can't you just revers your backspace and s key sends?
if ((Keys)keyCode== Keys.A)
{
SendKeys.Send("{BS}"); // remove A
SendKeys.Send("s"); // add S
}