SharpClipboard 2.0.5

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.

There is a newer version of this package available.
See the version list below for details.
Install-Package SharpClipboard -Version 2.0.5
dotnet add package SharpClipboard --version 2.0.5
<PackageReference Include="SharpClipboard" Version="2.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SharpClipboard --version 2.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SharpClipboard

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.

Features

Here's a comprehensive list of the features available:

  • Built as a component making it accessible in Design Mode.
  • Silently monitors the system clipboard uninterrupted; can also be disabled while running.
  • Ability to detect clipboard content in various formats, namely text, images, files, and other complex types.
  • Option to control the type of content to be monitored, e.g. text only, text and images only.
  • Ability to capture the background application's details from where the clipboard's contents were cut/copied.
    For example:
    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);
    }
    

Usage

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:

    var clipboard = new SharpClipboard();

    // Attach your code to the ClipboardChanged event to listen to cuts/copies.
    clipboard.ClipboardChanged += ClipboardChanged;
    
    private void ClipboardChanged(Object sender, ClipboardChangedEventArgs e)
    {
        // Is the content copied of text type?
        if (e.ContentType == SharpClipboard.ContentTypes.Text)
        {
            // Get the cut/copied text.
            Debug.WriteLine(clipboard.ClipboardText);
        }

        // Is the content copied of image type?
        else if (e.ContentType == SharpClipboard.ContentTypes.Image)
        {
            // Get the cut/copied image.
            Image img = clipboard.ClipboardImage;
        }

        // Is the content copied of file type?
        else if (e.ContentType == SharpClipboard.ContentTypes.Files)
        {
            // Get the cut/copied file/files.
            Debug.WriteLine(clipboard.ClipboardFiles.ToArray());

            // ...or use 'ClipboardFile' to get a single copied file.
            Debug.WriteLine(clipboard.ClipboardFile);
        }

        // If the cut/copied content is complex, use 'Other'.
        else if (e.ContentType == SharpClipboard.ContentTypes.Other)
        {
            // Do something with 'e.Content' here...
        }
    }

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<string> files = (List<string>)e.Content;

        // or other complex types too.
    }

Donate

Hey, you can always buy me a coffee if this component library (or others) has been of value to you.

SharpClipboard

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.

Features

Here's a comprehensive list of the features available:

  • Built as a component making it accessible in Design Mode.
  • Silently monitors the system clipboard uninterrupted; can also be disabled while running.
  • Ability to detect clipboard content in various formats, namely text, images, files, and other complex types.
  • Option to control the type of content to be monitored, e.g. text only, text and images only.
  • Ability to capture the background application's details from where the clipboard's contents were cut/copied.
    For example:
    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);
    }
    

Usage

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:

    var clipboard = new SharpClipboard();

    // Attach your code to the ClipboardChanged event to listen to cuts/copies.
    clipboard.ClipboardChanged += ClipboardChanged;
    
    private void ClipboardChanged(Object sender, ClipboardChangedEventArgs e)
    {
        // Is the content copied of text type?
        if (e.ContentType == SharpClipboard.ContentTypes.Text)
        {
            // Get the cut/copied text.
            Debug.WriteLine(clipboard.ClipboardText);
        }

        // Is the content copied of image type?
        else if (e.ContentType == SharpClipboard.ContentTypes.Image)
        {
            // Get the cut/copied image.
            Image img = clipboard.ClipboardImage;
        }

        // Is the content copied of file type?
        else if (e.ContentType == SharpClipboard.ContentTypes.Files)
        {
            // Get the cut/copied file/files.
            Debug.WriteLine(clipboard.ClipboardFiles.ToArray());

            // ...or use 'ClipboardFile' to get a single copied file.
            Debug.WriteLine(clipboard.ClipboardFile);
        }

        // If the cut/copied content is complex, use 'Other'.
        else if (e.ContentType == SharpClipboard.ContentTypes.Other)
        {
            // Do something with 'e.Content' here...
        }
    }

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<string> files = (List<string>)e.Content;

        // or other complex types too.
    }

Donate

Hey, you can always buy me a coffee if this component library (or others) has been of value to you.

Release Notes

Added support for Unicode characters.

Dependencies

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on SharpClipboard:

Repository Stars
C1rdec/Poe-Lurker
Ease your trading experience in Path of Exile.
Idered/snatch
📋 Beautiful clipboard manager for Windows
DeadlyCrush/DeadlyTrade
DeadlyTrade for Path Of Exile - (Overhaul Version) Trade Notification, Functional Overlay, Flask&Skill Timer, Map&Region Information, Real-Time Ninja Currency, Act Helper when Leveling and other useful functions.

Version History

Version Downloads Last updated
3.5.2 803 6/25/2020
3.5.1 417 5/15/2020
3.5.0 370 4/17/2020
3.4.0 142 4/10/2020
3.3.0 1,198 7/22/2019
3.1.0 221 7/11/2019
3.0.0 461 3/16/2019
2.0.7 277 2/23/2019
2.0.5 228 2/17/2019
2.0.3 228 2/7/2019
2.0.1 219 2/7/2019
2.0.0 217 2/7/2019
Show less