Ctrl+C 将剪贴板存储到变量 C#

Ctrl+C Store Clipboard to Variable C#

我可以使用 Sendkeys.Send("^c") 复制到剪贴板。

如何将剪贴板的内容存储到变量中?

 string setText = "somedata"; 
 Clipboard.SetText(setText);//copy text from variable to Clipboard
 string getText=Clipboard.GetText();// copy text from Clipboard to variable

取决于格式:

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);
    [..]
}