怎么在当前输入框粘贴文本?

mutouren168 2014-04-29 04:57:01
怎么在当前输入框粘贴剪贴板中的文本?
模拟CTRL+V就算了,有高手知道不,,,
...全文
191 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
小恒丶 2014-04-30
  • 打赏
  • 举报
回复
引用 10 楼 u011588826 的回复:
[quote=引用 9 楼 wg5945 的回复:]
粘贴:
private void button2_Click(object sender, System.EventArgs e) {
  // Declares an IDataObject to hold the data returned from the clipboard.
  // Retrieves the data from the clipboard.
  IDataObject iData = Clipboard.GetDataObject();
   
  // Determines whether the data is in a format you can use.
  if(iData.GetDataPresent(DataFormats.Text)) {
  // Yes it is, so display it in a text box.
  textBox2.Text = (String)iData.GetData(DataFormats.Text); 
  }
 }
这么大的粘贴两个字你没看到?
看到了,那我问你,他能粘贴到游戏和其他程序 里面么? [/quote] 你试都不试就问别人到底可不可以 别人都说是复制了啊。自己多动手试看看
mutouren168 2014-04-29
  • 打赏
  • 举报
回复
引用 9 楼 wg5945 的回复:
粘贴:
private void button2_Click(object sender, System.EventArgs e) {
  // Declares an IDataObject to hold the data returned from the clipboard.
  // Retrieves the data from the clipboard.
  IDataObject iData = Clipboard.GetDataObject();
   
  // Determines whether the data is in a format you can use.
  if(iData.GetDataPresent(DataFormats.Text)) {
  // Yes it is, so display it in a text box.
  textBox2.Text = (String)iData.GetData(DataFormats.Text); 
  }
 }
这么大的粘贴两个字你没看到?
看到了,那我问你,他能粘贴到游戏和其他程序 里面么?
wg5945 2014-04-29
  • 打赏
  • 举报
回复
粘贴:
private void button2_Click(object sender, System.EventArgs e) {
  // Declares an IDataObject to hold the data returned from the clipboard.
  // Retrieves the data from the clipboard.
  IDataObject iData = Clipboard.GetDataObject();
   
  // Determines whether the data is in a format you can use.
  if(iData.GetDataPresent(DataFormats.Text)) {
  // Yes it is, so display it in a text box.
  textBox2.Text = (String)iData.GetData(DataFormats.Text); 
  }
 }
这么大的粘贴两个字你没看到?
mutouren168 2014-04-29
  • 打赏
  • 举报
回复
引用 7 楼 wg5945 的回复:
复制:
private void button1_Click(object sender, System.EventArgs e) {
  // Takes the selected text from a text box and puts it on the clipboard.
  if(textBox1.SelectedText != ”")
  Clipboard.SetDataObject(textBox1.SelectedText);
  }

粘贴:
private void button2_Click(object sender, System.EventArgs e) {
  // Declares an IDataObject to hold the data returned from the clipboard.
  // Retrieves the data from the clipboard.
  IDataObject iData = Clipboard.GetDataObject();
  
  // Determines whether the data is in a format you can use.
  if(iData.GetDataPresent(DataFormats.Text)) {
  // Yes it is, so display it in a text box.
  textBox2.Text = (String)iData.GetData(DataFormats.Text); 
  }
 }
我想要的是粘贴功能,不是赋值哎。 我想写个粘贴器 ,因为游戏屏蔽CTRL+V按键,我又找不到粘贴对应的API
wg5945 2014-04-29
  • 打赏
  • 举报
回复
复制:
private void button1_Click(object sender, System.EventArgs e) {
  // Takes the selected text from a text box and puts it on the clipboard.
  if(textBox1.SelectedText != ”")
  Clipboard.SetDataObject(textBox1.SelectedText);
  }

粘贴:
private void button2_Click(object sender, System.EventArgs e) {
  // Declares an IDataObject to hold the data returned from the clipboard.
  // Retrieves the data from the clipboard.
  IDataObject iData = Clipboard.GetDataObject();
  
  // Determines whether the data is in a format you can use.
  if(iData.GetDataPresent(DataFormats.Text)) {
  // Yes it is, so display it in a text box.
  textBox2.Text = (String)iData.GetData(DataFormats.Text); 
  }
 }
mutouren168 2014-04-29
  • 打赏
  • 举报
回复
引用 5 楼 xdashewan 的回复:
内容你都获取了,还没办法展示?你写的是程序吗
游戏屏蔽CTRL+V按键,我想写个粘贴器
xdashewan 2014-04-29
  • 打赏
  • 举报
回复
内容你都获取了,还没办法展示?你写的是程序吗
mutouren168 2014-04-29
  • 打赏
  • 举报
回复
引用 2 楼 xdashewan 的回复:
用Clipboard
string data = Clipboard.GetText(TextDataFormat.UnicodeText);
这个是获得内容,我是想把内容显示出来,其实就是 CTRL+V,但是不知道他的API是什么
mutouren168 2014-04-29
  • 打赏
  • 举报
回复
引用 1 楼 m593192219 的回复:
读取剪贴板内容,判断是文本就显示
咋显示
xdashewan 2014-04-29
  • 打赏
  • 举报
回复
用Clipboard
string data = Clipboard.GetText(TextDataFormat.UnicodeText);
多啦A孟 2014-04-29
  • 打赏
  • 举报
回复
读取剪贴板内容,判断是文本就显示

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧