2

Is it possible to access the whole history of the clipboard (hourly, daily etc.) in Java?

After doing some research I've found the following code snippet which accesses the current item of the clipboard only:

import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;

String data = (String) Toolkit.getDefaultToolkit()
                .getSystemClipboard().getData(DataFlavor.stringFlavor);

But I am looking to get all the values in the history. How can I do that?

sticky_elbows
  • 1,344
  • 1
  • 16
  • 30

2 Answers2

4

You cannot. Clipboard is a single value container.

Antoniossss
  • 31,590
  • 6
  • 57
  • 99
  • When you view the clipboard using Windows Key + V, you can see multiple items in the history (assuming you have copied multiple items) – Some Guy Feb 03 '22 at 01:52
  • But those does not come from the clipborad obviously. you can track the history yourself in exactly the same way – Antoniossss Feb 03 '22 at 07:15
  • I don't understand; what do you mean we can track the history ourselves? – Some Guy Feb 03 '22 at 15:34
  • You have to listen to the changes, and "build" your history as you go. – Antoniossss Feb 03 '22 at 15:51
  • sa for WIN+V you forgot to mention that you have to ENABLE IT FIRST. By doing so, you are launching a background deamon that will build history from now on forward. It works just like that, queires clipboard and saves its content in repetition. – Antoniossss Feb 03 '22 at 15:53
3

Its not possible. Clipboard has only latest value stored.

Gokul Nath KP
  • 15,485
  • 24
  • 88
  • 126
  • When you view the clipboard using Windows Key + V, you can see multiple items in the history (assuming you have copied multiple items) – Some Guy Feb 03 '22 at 01:52
  • You forgot to mention that you have to ENABLE IT FIRST. By doing so, you are launching a background deamon that will build history from now on forward. – Antoniossss Feb 03 '22 at 15:52