wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes API to track clipboard changes ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "API to track clipboard changes ?" Watch "API to track clipboard changes ?" New topic
Author

API to track clipboard changes ?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

Is there any API which will notify me (Listener) whenever any changes occurs at system clipboard ?
I already know a method (by using Timer) to track clipboard changes but I think if i check for clipboard's data at 100ms then lots of CPU (which has just single core) time will be wasted


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
FlavorListener?
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

Michael Dunn wrote:FlavorListener?

i tried this but i guess, this listener only listens to the data flavour for eg: if i copy image using ctrl-c then listener gets invoked but when i again copy another image this time listener doesn't invoke
please run the code and check out whats happening , All I wanted to track is clipboard changes no matter what data is in clipboard but when ever user performs any copy operation i should get notification , is there a way (I know using Timer but it will consume lot of CPU)
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> but when i again copy another image this time listener doesn't invoke

seems to work if the clipboard contents are cleared, but then there'd be nothing to paste

might be easier, provided there's not a lot of text components, to just override copy(),
and put a notification in there.
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688


Michael Dunn wrote:
seems to work if the clipboard contents are cleared, but then there'd be nothing to paste

lolzzz

Michael Dunn wrote:
might be easier, provided there's not a lot of text components, to just override copy(),
and put a notification in there.

I didn't get what you are saying please elaborate ....
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
all text components inherit
cut() copy() paste()
from JTextComponent

you can override those methods, to do a number of things

run this, copy "Hello World", now try to paste it into the 2nd textField,
and again into the 3rd textField

same applies to cut() and copy()
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

ohhh! I m soory i guess you are not getting my requirement I want to monitor each & every thing which sits in system clipboard
so for eg :
if you copy a .exe into clipboard i should get notified that something has copied into clipboard (No matter what it is...)
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Well, Java's not really a good choice for writing spyware. You need a less well-behaved language for that.


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: API to track clipboard changes ?
 
Similar Threads
suggestions required for Java program
Transfer text on internet
Transfer text on internet
help and suggestions required in Java program
Is there any way of getting an image from the system clipboard?