.NET 中的 sendkeys 问题

发布于 2024-09-02 12:43:50 字数 184 浏览 1 评论 0原文

我有一个 Windows 应用程序,我在其中使用发送键从一个窗口导航到另一个窗口。我的发送按键序列就像在我的应用程序中激活另一个窗口,然后将击键发送到该窗口。但是我发送的击键在我激活另一个窗口的同一窗口中得到更新。

但经过几次按键后,它就会转到另一个窗口。似乎是发送键的同步问题。有没有办法指定当前发送键的操作完成后,再发送下一个发送键。

I have a windows application, where I am using send keys to navigate from one window to another. My send key sequence is like activating another window with in my app, and sending key strokes to that window. But the key strokes I am sending is getting updated in the same window where I am activating the other window.

But after few key strokes it is going to the other window. Seems like synchonization issue with send keys. Is there a way to specify the operation of the current send key is finished, before sending the next sendkey.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朦胧时间 2024-09-09 12:43:50

我发现 sendkeys 根本不可靠。请尝试使用输入模拟器

I have found sendkeys to be nothing but unreliable. Try the input simulator instead.

深海不蓝 2024-09-09 12:43:50

您是否尝试过使用 SendKeys.SendWait。这将等到密钥发送完毕并且操作处理完毕后再继续。

由于窗口位于您自己的应用程序中,为什么不提供一组函数来执行操作,而不是使用 SendKeys。一旦窗口创建并处于活动状态,函数就可以创建窗口,您可以通过处理 激活事件,然后您可以使用SendKeys将击键发送到新窗口,如果您确实需要的话,否则窗口类上再次有您可以调用的函数来携带列出击键将引发的操作。您可以定义一个通用的接口 Windows 实现来促进这种交互。

Have you tried using SendKeys.SendWait. This will wait until the key was sent and the action processed before carying on.

Since the windows are in your own application, why not provide set of functions to carry out the actions rather than using SendKeys. Functions can create the window once the windows in created and active which you can detect by handling the Activated event, you can then use SendKeys to send key strokes to the new window, if you really need to, otherwise again have functions on the window class that you can call to carry out the operations that the key strokes would induce. You could probably define a common interface that your windows implement to facilitate this interaction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文