I made a code that read each line in a richtextbox with a foreach.
foreach (string str in textBox3.Lines)
{
SendKeys.Send(str + " \n");
SendKeys.Send("{ENTER}");
}
But the problem is that it crashes because of the many lines. So what I thought is to make a timer after the the Enter sendkey. I tried it with Thread.Sleep and all kind of things that I've searched on the internet, but with no result.
Use SendWait
instead of Send
, it will not continue until the message has been processed by the receiver.
However, there are likely better ways to do what you want to do other than SendKeys
, if you add more details of what you are trying to accomplish I can try and update this answer with other potentially better options.