1

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?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Widunder
  • 295
  • 3
  • 19
  • Welcome to Stack Overflow Alina. Can you post your code where u have execute `SendKeys.Send("{SUBSTRACT}")` statement? So, we can debug it. – Shell May 27 '14 at 03:32
  • Hi, thanks! But this is all what it does really. I have my own application - not an external one. And there's a ultraGrid that accepts the - and + keys to expand/collapse the rows. All my automation is doing - is it selects a row and then uses SendKeys.SendWait("{SUBTRACT}"); to hopefully expand the row. But it's just not doing it at all – Widunder May 27 '14 at 03:42
  • So, you want to expand grid node on **Subtract** key down event? I have tried `SendKeys.Send("{SUBTRACT}")` statement. I have executed this line on button click and i got `-` written in my `Textbox`. So, it was working in my case. let me try to handle `Subtract KeyDown` event and call any specific method on it. – Shell May 27 '14 at 03:45
  • Is this windows application? – Shell May 27 '14 at 03:50
  • Try using it on an ultraGrid and see if you see the same issue. May be it's the ultraGrid control. And really appreciate your helping! – Widunder May 27 '14 at 03:59
  • 1
    I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders May 27 '14 at 04:18

1 Answers1

0

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);
}
Shell
  • 6,818
  • 11
  • 39
  • 70
  • Thank you sooo much! That worked! I still wonder though why the individual row expansion wasn't working for me. But that's alright :) definitely a solve :) Thank you! – Widunder May 27 '14 at 05:07