All Projects → undergroundwires → AsyncClipboardService

undergroundwires / AsyncClipboardService

Licence: MIT license
📋 An async & low-level windows clipboard service implementation for .NET, C#

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to AsyncClipboardService

CopyPasteJS
This a small JS library to execute clipboard functions in a fast and easy way.
Stars: ✭ 20 (+42.86%)
Mutual labels:  clipboard
clipsync-windows
Clipboard which sync with Android and Windows Platform.
Stars: ✭ 20 (+42.86%)
Mutual labels:  clipboard
nougat
Screenshot wrapper
Stars: ✭ 20 (+42.86%)
Mutual labels:  clipboard
async-permissions
Easy handling for Android-M permission based on async/await
Stars: ✭ 25 (+78.57%)
Mutual labels:  async-await
no-clipboard-app
Share your clipboard text to your device like Oculus Go.
Stars: ✭ 12 (-14.29%)
Mutual labels:  clipboard
typescript-async
Creating Asynchronous Code with TypeScript
Stars: ✭ 44 (+214.29%)
Mutual labels:  async-await
Vscode Paste Image
paste image from clipboard to markdown/asciidoc directly!
Stars: ✭ 236 (+1585.71%)
Mutual labels:  clipboard
Json-to-Dart-Model
marketplace.visualstudio.com/items?itemName=hirantha.json-to-dart
Stars: ✭ 84 (+500%)
Mutual labels:  clipboard
Copy-button
copy textview into anywhere
Stars: ✭ 14 (+0%)
Mutual labels:  clipboard
clipboard-watch
This is height performance clipboard watcher, support windows,osx
Stars: ✭ 21 (+50%)
Mutual labels:  clipboard
vim-poweryank
Copy text over SSH
Stars: ✭ 51 (+264.29%)
Mutual labels:  clipboard
copy-image-clipboard
Lightweight library to copy PNG and JPG images to clipboard
Stars: ✭ 37 (+164.29%)
Mutual labels:  clipboard
ImageClipboard.jl
Copy & Paste images with Julia
Stars: ✭ 33 (+135.71%)
Mutual labels:  clipboard
pyfuseki
A library that uses Python to connect and manipulate Jena Fuseki, which provides sync and async methods.
Stars: ✭ 22 (+57.14%)
Mutual labels:  async-await
TeamSpeak3QueryApi
.NET wrapper for the TeamSpeak 3 Query API
Stars: ✭ 56 (+300%)
Mutual labels:  async-await
awaitwhat
Await, What?
Stars: ✭ 48 (+242.86%)
Mutual labels:  async-await
WinPopclip
Popclip alternative for Windows
Stars: ✭ 76 (+442.86%)
Mutual labels:  clipboard
promisify-child-process
seriously like the best async child process library
Stars: ✭ 54 (+285.71%)
Mutual labels:  async-await
Pyrez
(ON REWRITE) An easy to use (a)sync wrapper for Hi-Rez Studios API (Paladins, Realm Royale, and Smite), written in Python. 🐍
Stars: ✭ 23 (+64.29%)
Mutual labels:  async-await
uniclip
Cross-platform shared clipboard
Stars: ✭ 116 (+728.57%)
Mutual labels:  clipboard

AsyncWindowsClipboard

NuGet version NuGet downloads Build status contributions welcome Maintainability

AsyncWindowsClipboard is thread-safe, asynchronous windows clipboard service with retry strategy for .NET

What it is

  • It gives async/await syntax to communicate with Windows clipboard API's.
  • It is thread safe.
  • It gives lower (binary) level read & write access to strings in clipboard than .NET implementation.
  • Implements retry strategies to connect to the clipboard when it's locked.

How it works

AsyncClipboardService ensures that:

  • The Tasks for the communication always run in the same thread which makes the communication thread safe.
  • The thread is in Single Thread Apartment (STA) model. WPF & Windows Forms uses COM interop to communicate with clipboard in STA state. Running the thread in same apartment state ensures that the library functions well. Read more at MSDN 1, 2, 3.
  • Implements retry strategy to ensure clipboard operation ends successfully.

How to use

Simple usage

You can use a new instance of WindowsClipboardService to retrieve data. It's okay to use the instance from different threads.

    var clipboardService = new WindowsClipboardService();
    await clipboardService.SetTextAsync("Hello world"); // Sets the text
    var data = await clipboardService.GetTextAsync(); // Reads "Hello world"

Recommended usage

However, it's recommended to use WindowsClipboardService with a timeout strategy, as it'll then wait (in a spinning state) for the thread that blocks the windows api instead of failing. You can activate the timeout strategy by setting it in the constructor:

    var clipboardService = new WindowsClipboardService(timeout:TimeSpan.FromMilliseconds(200)); 
    // or via its property
    var clipboardService = new ClipboardService { Timeout = TimeSpan.FromMilliseconds(200) };

Contribute

Fork → Modify → Pull request

What's supported so far are :

  • Text read + write
  • Unicode bytes read + write
  • File drop list read + write

Missing (contributions are welcomed):

  • Audio read + write
  • Image read + write

For reference implementations, take look at Readers and Writers.

License

This project is MIT Licensed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].