kenan2002 / electron-clipboard-ex

47 stars 9 forks source link

electron-clipboard-ex

A node.js native addon designed to use with electron to extend its clipboard features.

Travis npm version

Example

Read file paths copied from macOS Finder or Windows explorer:

const clipboardEx = require('electron-clipboard-ex');
const filePaths = clipboardEx.readFilePaths();

Write file paths to clipboard:

const clipboardEx = require('electron-clipboard-ex');
clipboardEx.writeFilePaths(filePaths);

Clear clipboard:

const clipboardEx = require('electron-clipboard-ex');
clipboardEx.clear();

Save clipboard image as jpeg:

const clipboardEx = require('electron-clipboard-ex');
// sync
clipboardEx.saveImageAsJpegSync(targetPath, compressFactor);
// async
await clipboardEx.saveImageAsJpeg(targetPath, compressFactor);

Save clipboard image as png:

const clipboardEx = require('electron-clipboard-ex');
// sync
clipboardEx.saveImageAsPngSync(targetPath);
// async
await clipboardEx.saveImageAsPng(targetPath);

Put image into clipboard:

const clipboardEx = require('electron-clipboard-ex');
// sync
clipboardEx.putImageSync(imagePath);
// async
await clipboardEx.putImage(imagePath);

Check if clipboard has an image in it:

const clipboardEx = require('electron-clipboard-ex');
clipboardEx.hasImage();

Operating system support

This library supports Windows and macOS. Linux is currently not supported, feel free to open a pull request if you need it.