A library for anonymously monitoring clipboard entries.
A library for anonymously monitoring clipboard entries.
SharpClipboard is a clipboard-monitoring library for .NET that listens to the system's clipboard entries, allowing developers to tap into the rich capabilities of determining the clipboard's contents at runtime.
Here's a screenshot and below a usage-preview of the library's features:
To install via the NuGet Package Manager Console, run:
Install-Package SharpClipboard
If you prefer working with the Designer, simply add the library to Visual Studio's Toolbox and use the Properties window to change its options:
To use it in code, first import WK.Libraries.SharpClipboardNS - the code below will then assist you:
…You can also get the details of the application from where the clipboard's contents were cut/copied from using the ClipboardChanged argument property SourceApplication:
private void ClipboardChanged(Object sender, SharpClipboard.ClipboardChangedEventArgs e)
{
// Gets the application's executable name.
Debug.WriteLine(e.SourceApplication.Name);
// Gets the application's window title.
Debug.WriteLine(e.SourceApplication.Title);
// Gets the application's process ID.
Debug.WriteLine(e.SourceApplication.ID.ToString());
// Gets the application's executable path.
Debug.WriteLine(e.SourceApplication.Path);
}This option could come in handy especially when you're building a clipboard-monitoring application where users may feel the need to know where every recorded cut/copy action occurred.
To manually parse the content after a cut/copy has been detected, you can use the argument property e.Content in the ClipboardChanged event:
private void ClipboardChanged(Object sender, ClipboardChangedEventArgs e)
{
// For texts...
string text = e.Content.ToString();
// or images...
Image img = (Image)e.Content;
// or files...
List files = (List)e.Content;
// or other complex types too.
// Person p = JsonConvert.DeserializeObject(e.Content);
}Made with by Willy Kimura | Like to say thank you? Star this project. Feel free to BuyMeACoffee also.
No open issues yet, or sync has not completed.