将文本粘贴到外部应用程序中 [英] Paste text into outside Application

查看:77
本文介绍了将文本粘贴到外部应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想制作一个ac#应用程序,以检测活动窗口并检测是否在其中放置了文本框(显然,此文本框应该是窗体的焦点控件),然后将某些文本粘贴到该窗口中文本框.
注意:我们要在其中粘贴文本的应用程序不是我们的c#应用程序,也不是网页. b>


我想要的只是一些想法建议关于如何实现此目标...
预先感谢.

Hi,,
I want to make a c# app that detects the active window and detects if a textbox is placed in it (Obviously this textbox should be the focused control of the form), and then pastes a certain text into this textbox.
NOTE: The application we are going to paste text in it is NOT our c# application AND is not a web page.


All I want is some ideas or suggestions on how this could be made...
Thanks in advance.

推荐答案

HI ..,

我认为您可以使用发送键来实现这一目标,请参阅
中的CP文章 下面的链接..,您必须使用此包装器创建自己的应用程序
将击键发送到C#中的另一个应用程序 [
HI ..,

i think you can achive this by using send keys , see the CP article in
the below link.., you have to made your own application by using this wrappers
Sending Keystrokes to another Application in C#[^]

First you have to active the window(third party application).
   <pre lang="midl">int iHandle = NativeWin32.FindWindow(null, txtTitle.Text);
NativeWin32.SetForegroundWindow(iHandle);





请参阅上面的代码块,如何激活第三方应用程序窗口.然后发送TAB键以聚焦所需的文本框.选择文本并复制到剪贴板,然后激活c#应用程序将其粘贴到所需的位置. (选择和复制您也可以使用发送键来完成).

此解决方案不能100%地帮助您,但您会有所想法的..

谢谢&问候
Rajesh B





see the above code block how to active the window of third party application. then send the TAB keys to focus the text box which you want. select the text and copy to clip board, then activate your c# application paste it where you want. (selection and copy also you can done with SEND KEYS).

This solution will not help you 100%, but you will get an idea ..

Thanks & Regards
Rajesh B


使用剪贴板类

按照链接

http://msdn.microsoft.com/zh-cn/library/system.windows.forms.clipboard.aspx
Use clipboard class

follow the link

http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard.aspx


OK请提供实时场景或简短说明.我可以进一步帮助您.
如我所发布的那样,如果您使用剪贴板类U可以在剪贴板上复制文本或其他内容,并且可以在任何地方粘贴,
意味着任何应用..
使用CTRL + V ..

通过您的评论PLS ...
OK PLEASE GIV A LIVE SCENARIO OR A BRIEF DESCR.. SO THAT I COULD HELP U FURTHER.
AS I VE POSTED IF U USE CLIPBOARD CLASS U CAN COPY TEXT OR OTHER TO CLIPBOARD AND CAN BE PASTED ANY WHERE,
MEANS ANY APPLICATION..
USING CTRL+V..

PASS UR COMMENTS PLS...


这篇关于将文本粘贴到外部应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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