时间:2019-03-17 标签:c#sendkeys之间暂停
我正在基于 Java 的网页上进行一些自动化操作,需要在条目之间进行一些验证,因此我想我只需在每个 SendKeys.Send< 之间执行
Thread.Sleep
即可/code>,但由于某种原因,它在加载页面时只休眠 10 秒(10 x 1 秒暂停),然后浏览整个表单,而不会在每次按键之间暂停。
任何人都知道为什么要这样做,或者有任何关于实现发送键之间暂停的替代方法的建议吗?
Thread.Sleep(1000);
SendKeys.Send("{TAB}");
Thread.Sleep(1000);
SendKeys.Send(strTEST);
这是在 browser_DocumentCompleted
事件上
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要暂停,您需要使用 SendWait 函数而不是 SendKeys: http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.sendwait(v=VS.90).aspx
SendKeys 将所有密钥排队并稍后处理它们,如您所见。 SendWait 处理它们并返回。
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.