Skip to content

MasterDevs/Clippy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clippy Build status NuGet version

Treat the clipboard like a TextReader and TextWriter

Installation

PM> Install-Package MasterDevs.Clippy

Usage

We use System.Windows.Clipboard to read and write to the clipboard. Since this is an OLE object it needs to be accessed from a STAThread. If you are in a WPF application, you shouldn't need to worry about this. If you are in a console application, you will need to make sure that you are using a STAThread. The easiest way is to decorate your startup method with the STAThreadAttribute like so:

[STAThread]
private static int Main(string[] args)
{
  // ...
}

Reading from the clipboard

To read from the clipboard, simply create a new ClipboardReader

using (var clippy = new ClipboardReader())
{
  var clipboardText = clippy.ReadToEnd();
}

Writing to the clipboard

To write to the clipboard, simply create a ClipboardWriter

using (var clippy = new ClipboardWriter())
{
  clippy.Write("Hello World");
}

About

Treat the clipboard like a TextReader and TextWriter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages