This site uses cookies own and third. If you continue to browse consider to accept the use of cookies. OK More Info.

Monitoriar el Clipboard

  • 0 Replies
  • 2347 Views

0 Members and 1 Guest are viewing this topic.

Offline ProcessKill

  • *
  • Underc0der
  • Posts: 154
  • Actividad:
    0%
  • Reputación 0
  • Arriba los hackers de Argentina!
    • View Profile
    • Email

Monitoriar el Clipboard

  • on: February 24, 2010, 04:13:53 pm
implementado en mi jdeff downloader con algunas moficicaciones ;)

Code: (java) You are not allowed to view links. Register or Login
import java.awt.datatransfer.Transferable;
/*
 
 @author L-EYER
 @see GlassFish Tools Bundle For EclipseVersion: 0.9.9
   
*/
public class ThreadClipboard extends Thread{
public static void main(String[] args){
new ThreadClipboard();
}
public ThreadClipboard(){this.start();}
private boolean _run = true;
private String string;
private Transferable transferable;
    private final String getClipboard()
    {
    transferable =
    java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
        try {
            if (transferable != null &&
            transferable.isDataFlavorSupported(
            java.awt.datatransfer.DataFlavor.stringFlavor)) {
                string =
                (String)transferable.getTransferData(
                java.awt.datatransfer.DataFlavor.stringFlavor);
                return string;
            }
        } catch ( java.awt.datatransfer.UnsupportedFlavorException exception)
        {System.err.println(exception);_run = false;System.exit(0);
        } catch (java.io.IOException e)
        {System.err.println(e);System.out.println("GClipboard.getClipboard()");
        _run = false;System.exit(0);
        }
        return null;
    }
public String getText() {return string;}
public void setText(String text) {this.string = text;}
public boolean is_run() {return _run;}
public void set_run(boolean _run) {this._run = _run;
}
private int DELAY = 50;
@Override public synchronized void run()
{
while(is_run()){
try {
String stringClipboard = getClipboard();
if(stringClipboard!= null){
System.out.println(stringClipboard);
    }
else{continue;
    }
Thread.sleep(DELAY);
   } catch (InterruptedException e) {
System.err.println(e);System.exit(0);
   }
}
   }
}

BYEE  8)
« Last Edit: April 18, 2013, 12:43:17 pm by Expermicid »