sudhakar3697 / node-clipboard-event Goto Github PK
View Code? Open in Web Editor NEWClipboard change event for Node.js/Electron.js/NW.js
Home Page: https://www.npmjs.com/package/clipboard-event
License: MIT License
Clipboard change event for Node.js/Electron.js/NW.js
Home Page: https://www.npmjs.com/package/clipboard-event
License: MIT License
Hi @sudhakar3697
I'm using your clipboard-event module in my electron and so far it is grate.
However, I'm observing that if I use this module and when my app launches, the focus first lands to my app and then an invisible window spawns with the title of clipboard-event-handler-win32.
This hidden/invisible window steals our focus from the application which is not good for the users.
If we unknowingly press alt+f4 on that window, the clipboard events in our app stops working.
Can you help here? I guess some executable is getting launched for capturing the clipboard which is spawning the invisible window.
Can you do something to hide that window?
(I'm on Windows)
(I'm targetting keyboard users mainly with this app)
Awesome library. It does the job pretty well!
I would suggest to provide the types, to make it easier to integrate with TypeScript.
I have a Electron app which uses clipboard-event package in ubuntu 20 and works fine. Now I want to run it in Ubuntu 22 for development and I saw that clipboard changes where not detected. The cause is that in the package the data received from the compiled clipboard handler is checked if it is equal to "CLIPBOARD_CHANGE". However, the data it is receiving is "CLIPBOARD_CHANGE\nCLIPBOARD_CHANGE". As a result the comparation is false and the event is not emitted.
Did anyone had this behaviour?
t
Hi, i have this problem, node-clipboard-event doesn't work for me when I call it in electron
I have a test file called test.js, when I open it with "node test.js" it works perfect
const clipboardListener = require('clipboard-event');
clipboardListener.startListening();
clipboardListener.on('change', () => {
console.log("hi")
});
but... if I call this file from background.js (electron) it just doesn't do anything
also if I put the code directly in background.js it does nothing
I have the nodeIntegration: true. Why doesn't it work in electron but with "node" directly?
Nothing happens when copying text even though I have copied the example from the repo.
OS: Ubuntu 22.04.2
Node version: 16.16.0
Code:
const cL = require("clipboard-event");
console.log("Running"); // THIS RUNS
cL.startListening();
cL.on("change", () => {
console.log("Test") // NEVER RUNS
}
console.log(cL); // Shows ClipboardEventListener object with evensCount: 1 (so event has registered correctly)
Hi @sudhakar3697
I've checked that you have the "v2" branch for the native module of node-clipboard-event in this repository but it is not updated since 2020.
So, are there any plans to develop/support the native module further? Actually I needed the native implementation for one of my electron project and I don't want to use the module based on child_process.
Please help
I was trying to use this library using https://github.com/WilianZilv/reactron ( React + Electron ). Here's the code that I tried:
import React from 'react';
import Grid from "@material-ui/core/Grid";
import {useOvermind} from "../Others/OvermindHelper";
import {on, startListening} from 'clipboard-event'
import Button from "@material-ui/core/Button";
const sl = () => {
startListening()
console.log("Clipboard Listening")
on('change', () => {
console.log('Clipboard changed');
});
}
const Clipboard = () => {
const {state, actions} = useOvermind()
return (
<Grid>
<Button variant='contained' color='primary' onClick={() => {
sl()
}}>START</Button>
</Grid>
);
};
export default Clipboard;
Any solution?
Thanks...
Hi @sudhakar3697,
Thanks for creating this valuable package! I used your example code in an electron desktop application, but did not detect any clipboard changes:
package.json:
"dependencies": {
"clipboard-event": "^1.5.0"
},
Installation: npm install
// Monitor clipboard changes
import clipboardListener from "clipboard-event";
// To start listening
clipboardListener.startListening();
clipboardListener.on('change', () => {
console.log('Clipboard changed');
});
Reason is that the executable has no exec permission after installation:
/node_modules/clipboard-event/platform$ ll
total 124
drwxrwxr-x 2 a a 4096 Jul 2 21:29 ./
drwxrwxr-x 3 a a 4096 Jul 2 21:29 ../
-rw-rw-r-- 1 a a 12928 Oct 26 1985 clipboard-event-handler-linux
-rw-rw-r-- 1 a a 1081 Oct 26 1985 clipboard-event-handler-linux.c
-rw-rw-r-- 1 a a 75440 Oct 26 1985 clipboard-event-handler-mac
-rw-rw-r-- 1 a a 394 Oct 26 1985 clipboard-event-handler-mac.swift
-rw-rw-r-- 1 a a 1973 Oct 26 1985 clipboard-event-handler-win32.cs
-rw-rw-r-- 1 a a 8696 Oct 26 1985 clipboard-event-handler-win32.exe
Manually setting it solved it:
$ chmod +x clipboard-event-handler-linux
Output:
Clipboard changed
Clipboard changed
Clipboard changed
Can you add this into Git?
$ git update-index --chmod=+x clipboard-event-handler-linux
$ git ls-files --stage
$ git push
Thanks!
clipboard-event-handler-mac
does not start properly on Mac.
Processes are automatically killed when executed in the terminal.
If you use the following terminal command before executing:
chmod +x ./clipboard-event-handler-mac
you will get an error: clipboard-event-handler-mac
will harm your computer and you should move it to the Trash.
Other than that, it executes fine under Linux and Win.
I don't know how to fix this, if anyone could provide a little advice, I'd be grateful! ๐ข
I dont know why , but when i open my file try.js:
const clipboardListener = require('clipboard-event');
clipboardListener.startListening();
clipboardListener.on('change', () => {
console.log('Clipboard changed');
}
with "node try.js" work good, but...
when i use "pkg try.js --target node14-win-x64" and open the file try.exe (the same file this literally) just close whiout show error. Am I the only one that this happens to? or is it a bug in this package?
Was using this package while developing on a Linux (Ubuntu) machine, but apparently, the package was not working as intended, after going through the source, and found out that the system was not able to execute the Linux file named 'clipboard-event-handler-linux' which is an executable I suppose. And this was happening because the file did not have execute permission.
To give permission to the file:
$ chmod u+x <PROGRAM_DIRECTORY>/node_modules/clipboard-event/platform/clipboard-event-handler-linux
Also, my flavor of ubuntu apparently does not use xclip for clipboard based events so had to run sudo apt install xclip
Anywho, got it running, Just wrote this for reference is case anyone is having a hard time!
Cheers!
Is it possible to create separate Listeners for cut,copy and paste? Something like this
clipboardListener.on('cut', () => { // When text is cut });
clipboardListener.on('copy', () => { // When text is copied });
clipboardListener.on('paste', () => { // When text is pasted });
Is there any way to get the clipboard content like:
const clipboardListener = require('clipboard-event');
clipboardListener.startListening();
clipboardListener.on('change', (content) => {
console.log('Clipboard changed, content: ' + content);
});
clipboardListener.stopListening();
I think it would be nice if the callback would get infos:
clipboardListener.on('change', (e) => {
console.log('Clipboard changed: ' + e.text);
});
Or rather - I'd need any way to get the clipboard's content after the event triggered.
Hey bro,
First of all thanks a lot for this amazing module.
Actually I'm working on a clipboard manager and I want to take some action when user copies some text to the clipboard. However, I'm unable to find the detail/implementation that how to access the clipboard data/text in
clipboardListener.on("change", () => {
}
here, there's no parameter for the data.
Please help
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.