SendKeys {SUBTRACT} not working

1.2k views Asked by At

I've searched the Internet and this web site for any clues to fix my issue, but haven't found one. I have a method that expects a string and then does SendKeys.SendWait(str). Everything works like passing in "{ENTER}" or just typing normal text.

But! If I pass in "{SUBTRACT}" it just doesn't work. I've also tried passing in the ASCII presentation of the key, but it threw exception that its unsupported.

I've also tried just doing SendKeys.Send("{SUBTRACT}") - no results what so ever.

Its just not doing anything. However, when I press the minus button on the keypad or on the top of the keyboard - functionality works.

Please note that this is using windows Automation Framework. May be this is what causing the problem. Has anyone had the same issues?

1

There are 1 answers

1
Shell On BEST ANSWER

I have tried to show messagebox on Subtract KeyDown event. I have sent Subtract key on my button click event. But, make sure you have enabled KeyPreview property of your windows form.

private void button1_Click(object sender, EventArgs e)
{
    SendKeys.Send("{SUBTRACT}");
}

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Subtract)
        this.UltraGrid1.Rows.CollapseAll(true);
}