如何从文本框中复制文本并复制到其他程序 [英] How to copy a text from a textbox and copy to an other program

查看:134
本文介绍了如何从文本框中复制文本并复制到其他程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将我加载到C#程序中的文本框中的文本复制到剪贴板,并且在4秒计时器之后将复制的文本粘贴到其他窗口(C#程序的外侧) 。

我不知道如何处理这个的复制/粘贴位。

此外,应使用tab将文本复制到其他程序的不同字段中。

关于这些问题的任何想法?



只有1个程序是第三方,源程序是我们将在内部开发的程序。

我们实际上需要内部程序来复制我加载到其中的文本并将其粘贴到第三方程序中。

我的实际问题是C#我应该使用代码来自动复制文本并在我点击第三方程序文本框时自动粘贴它。

I would like to be able to copy a text that I load into a textbox in a C# program to the clipboard and that the copied text is pasted in an other window (out side of the C# program) after a 4 second timer.
I''m not sure how to handle the copy / paste bit of this.
Also the text should be copied in to different fields of the other program using tab.
Any ideas on those issues?

Only 1 program is a third-party, the source program is one we will develop in house.
We actually need the in-house program to copy the text which I loaded into it and paste it in the third-party program.
My actual question is what C# code should I use to be able to automatically copy the text and automatically paste it when I click in the third-party program textbox.

推荐答案

复制部分很简单,只需使用 剪贴板 [ ^ ]并将您的数据放入其中。粘贴必须由接收程序完成,但您可以通过Windows消息发出信号,例如 WM_PASTE [ ^ ]。
The copy part is easy, just use the Clipboard Class[^] and put your data into it. The pasting will have to be done by the receiving program, but you can signal it with a Windows message, such as WM_PASTE[^].


private void CopyTemplate()
       {
           TimerText.Text = "Copying";
           SendKeys.SendWait("{HOME}");
           SendKeys.SendWait("Update ticket on ticket: ");
           SendKeys.SendWait("{TAB}");
           SendKeys.SendWait("Regarding ticket: " + ValueCopy + "");
           SendKeys.SendWait("{ENTER}");
           SendKeys.SendWait("Summary: ");
           SendKeys.SendWait("{TAB}{TAB}{TAB}");
           SendKeys.SendWait("{ENTER}");
           SendKeys.SendWait("+{TAB}+{TAB}+{TAB}");
           SendKeys.SendWait("{ENTER}{ENTER}");

           textBox1.SelectAll();
           textBox1.Copy();
           SendKeys.SendWait("^{V}");

           SendKeys.SendWait("{ENTER}{ENTER}{ENTER}{ENTER}{ENTER}");
           SendKeys.SendWait("{TAB}{TAB}{TAB}");
           SendKeys.SendWait("{ENTER}");
           SendKeys.SendWait("+{TAB}+{TAB}+{TAB}");

           SendKeys.SendWait("{ENTER}{ENTER}");
           SendKeys.SendWait("{TAB}{TAB}{TAB}{TAB}");
           SendKeys.SendWait("{ENTER}");
           SendKeys.SendWait("+{TAB}+{TAB}+{TAB}+{TAB}");

           TimerText.Text = "Done";
           StartDoneTimer();
       }


这篇关于如何从文本框中复制文本并复制到其他程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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