0.0.5 • Published 1 year ago

general-clipboard-listener v0.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

This project is moved to CrossCopy. https://github.com/CrossCopy/clipboard

This repo will be not be maintained and will be archived.

New NPM Package: https://www.npmjs.com/package/@crosscopy/clipboard

General Clipboard Listener

A Cross-Platform clipboard listener that listens for both text and image (screenshots).

npm package: https://www.npmjs.com/package/general-clipboard-listener

Installation

npm i general-clipboard-listener

Usage

It has a very easy to use event-based system.

See demo.ts for a demo.

Run ts-node demo.ts.

import clipboardEventListener from "./index";

clipboardEventListener.on("text", () => {
  console.log("Clipboard Text Updated");
});

clipboardEventListener.on("image", () => {
  console.log("Clipboard Image Updated");
});

clipboardEventListener.on("open", (data) => {
  console.log(data);
});

clipboardEventListener.startListening();

setTimeout(() => {
  clipboardEventListener.stopListening();
}, 10000);

Explanation

It's achieved using child process + stdout.

I took a golang version of the listener from golang-design/clipboard.

When a change is detected, IMAGE_CHANGED or TEXT_CHANGED is printed to stdout.

This library runs compiled go-version clipboard listener using child process and listen to the stdout.

If it sees the keywords in child process's stdout, an event will be emitted.

Run npm run demo to see a demo for 10 sec. Once started, copy some text and screenshot and check the terminal.

Supported Platforms

Format: process.platform/process.arch

The process here is from nodejs.

Supported platforms can be found in go-clipboard-monitor.

If your nodejs gives different platform or arch, it may not work.

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago