SendKeys GUI Bug

I've made this program in C#:

namespace Spammer
{
    public partial class Form1 : Form
    {
        int delay, y = 1;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            delay = int.Parse(textBox2.Text);
            timer1.Interval = delay;
            timer1.Enabled = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
                String textt = textBox1.Text;
                SendKeys.SendWait(textt);
        }
    }
}

It works fine most of the time, and it can really send keys quickly.

But when I insert a delay of, for example, 10 MS, it's very hard to click the "Stop" button to stop it. The only way to stop the sending is to close the program and I don't want to do that.

Is there anyway I can send keys very quickly, like 5-10 MS, without it impairing my ability to press the buttons inside the program? I can't click while it's sending quickly...

Jon Skeet
people
quotationmark

The problem is that you're using SendWait. That will wait for the target application to respond - and while that's happening, your application won't be able to respond to user input. If you use Send instead of SendWait, your UI thread won't be blocked waiting for the key press to be processed.

people

See more on this question at Stackoverflow