Ctrl+C存储剪贴板到变量c#
本文关键字:变量 剪贴板 存储 Ctrl+C | 更新日期: 2023-09-27 18:12:14
我可以使用Sendkeys.Send("^c")复制到剪贴板。
如何将剪贴板的内容存储到变量中?
视格式而定:
if (Clipboard.ContainsAudio())
{
var audio = Clipboard.GetAudioStream();
[..]
}
if (Clipboard.ContainsFileDropList())
{
var list = Clipboard.GetFileDropList();
[..]
}
if (Clipboard.ContainsImage())
{
var image = Clipboard.GetImage();
[..]
}
if (Clipboard.ContainsText(TextDataFormat.Html))
{
var text = Clipboard.GetText(TextDataFormat.Html);
[..]
}
string setText = "somedata";
Clipboard.SetText(setText);//copy text from variable to Clipboard
string getText=Clipboard.GetText();// copy text from Clipboard to variable