Click here to Skip to main content
15,904,288 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am new to windows app development. I am developing a Windows Form Application where the layout is as follows:

There is one textbox and i have created the keyboard inside the application using SendKeys event.

Problem is that all other application on the system are able to detect the keys but the textbox inside the application is not able to detect the keys.

What I have tried:

protected override CreateParams CreateParams
        {
            get
            {
                CreateParams param = base.CreateParams;
                param.ExStyle |= 0x08000000;
                return param;
            }
        }

private void button14_Click(object sender, EventArgs e)
        {//one of the Key in Keyboard
            if (checkBox1.Checked)
            {
                SendKeys.Send("Q");
            }
            else
            {
                SendKeys.Send("q");
            }
        }

private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
Posted
Updated 9-Jul-18 6:33am
v3
Comments
Richard MacCutchan 6-Jul-18 4:29am    
You are sending the keys to the active window and whichever control has the focus. In your case buton14 will have the focus.

1 solution

Set the focus to textBox1 right before calling SendKeys.Send() to be sure that's what has focus to receive the input.

C#
textBox1.Focus();
SendKeys.Send("Q");
 
Share this answer
 

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