SendKeys.SendWait("^c") 问题 [英] SendKeys.SendWait("^c") problem

查看:27
本文介绍了SendKeys.SendWait("^c") 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的后台应用程序复制活动应用程序中的选定文本.我使用 SendKeys.SendWait().但有时我会遇到问题:一段时间后,我的应用程序仅发送c"而没有CTRL"(至少只有c"进入活动应用程序).

I want to copy selected text in active application from my application in background. I use SendKeys.SendWait(). But i have a problem sometimes: after a while my application sends only "c" without "CTRL" (at least only "c" comes to active application).

有人可以帮忙吗?

感谢您的建议....

推荐答案

我建议你把 SendKeys 放在一起,因为它是失败的秘诀.在您复制、激活窗口和粘贴数据之间可能发生太多事件.

I would suggest you drop the SendKeys all together, as it is a recipe for failure. There are too many events that can happen between the time you copy, activate a window, and paste your data.

我相信完成任务的最佳方法之一是使用 SendMessage API,您可以将其互操作到您的项目中.

I believe one of the best ways to accomplish your task would be to use the SendMessage API, which you can interop into your project.

与激活应用程序并通过 SendKeys 发送不同,您实际上可以在外部应用程序中挂钩文本框的句柄,并将目标设置为您希望粘贴的字符串.这将保证您尝试发送到应用程序的数据将到达那里,而不管在操作期间弹出或聚焦的任何其他窗口.

Instead of activating an application and sending via SendKeys, you can essentially hook the handle of the textbox in the external application and set the target equal to the string you wish to paste. This will guarantee the data you are attempting to send to the application will get there, regardless of any other windows that popup or focus during the operation.

我会看看这个教程,它已经构建了一些类来帮助您发布数据.

I would look at this tutorial, which already has classes built to help you post your data.

c-win32-messaging-with-sendmessage-and-wm_copydata

这篇关于SendKeys.SendWait("^c") 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆