本文介绍了如何保存在剪贴板中的副本,然后恢复到了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过模拟需要highligh和复制的文本的按键阅读文本框中的话。当我做,我想剪贴板是正是我发现它

I'm reading words in a text box by simulating the key presses required to highligh and copy the text. When I'm done, I want the clipboard to be exactly how I found it.

我希望我能够做这样的事:

I was hoping I'd be able to do something like this:

IDataObject clipboardBackup = Clipboard.GetDataObject();
Clipboard.Clear();
//Save other things into the clipboard here, etc//
Clipboard.SetDataObject(clipboardBackup);



但是,这似乎并没有工作。它看起来像你可以去专门尝试了文本,音频,图片等,然后保存它们相应的路由。 (我猜数据对象是专业一样,在我的例子太多,我希望这是通用的。)

But that doesn't seem to work. It looks like you can go the route of specifically trying for text, audio, pictures, etc. and then saving them accordingly. (I guess 'data object' is specialized like that in my example too, I was hoping it was generic.)

我宁愿不使用的情况下每一个可能的剪贴板中的数据类型,既​​要更简洁,以确保我永远不会丢失数据,无论格式。

I'd prefer not to use cases for every possible type of clipboard data, both to be more concise and to make sure I never lose the data regardless of format.

有关抓住任何和所有剪贴板中,然后任何提示恢复呢?

Any tips for grabbing any and all of the clipboard and then restoring it?

推荐答案

不要使用剪贴板,除非直接指示由登录的用户这样做。这不是一般的应用程序存储 - 这是为用户使用什么样的他们的要裁剪

Do not use the clipboard unless directly instructed to do so by the logged-on user. It's not for general application storage - it's for the user to use for what they want to clip.

如果你想从获取文本任意文本框,找到该窗口(在Win32)感和发送 EM_GETTEXT Win32的消息。

If you want to get text from an arbitrary textbox, locate the window (in the Win32) sense and send an EM_GETTEXT Win32 message.

这篇关于如何保存在剪贴板中的副本,然后恢复到了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 15:20