Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# Pausing between sendkeys

I'm doing some automation on a Java-based web page that needs to do some validation between entries, so I thought I'd just do a Thread.Sleep between each SendKeys.Send, but for some reason it just sleeps for 10 secs (10 x 1sec pauses) as it loads the page and then shoots through the whole form without pausing in between each keypress.

Anyone any ideas why it's doing this, or any suggestions for an alternative way of achieving a pause between sendkeys?

Thread.Sleep(1000);
SendKeys.Send("{TAB}");
Thread.Sleep(1000);
SendKeys.Send(strTEST);

this is on a browser_DocumentCompleted event

like image 700
rs82uk Avatar asked Oct 24 '22 09:10

rs82uk


1 Answers

To pause, you want to use the SendWait function instead of SendKeys: http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.sendwait(v=VS.90).aspx

SendKeys queues all the keys up and processes them later, as you are seeing. SendWait processes them and returns.

like image 159
Ed Bayiates Avatar answered Nov 09 '22 06:11

Ed Bayiates