Created
September 22, 2012 06:10
-
-
Save TonyWhite/3765318 to your computer and use it in GitHub Desktop.
Parkinson
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.awt.datatransfer.*; | |
| import java.awt.*; | |
| public class JClipboard implements ClipboardOwner | |
| { | |
| /** | |
| * Incolla nella Clipboard | |
| */ | |
| public void toClipboard(String contenuto) | |
| { | |
| StringSelection st = new StringSelection(contenuto); | |
| Clipboard cp = Toolkit.getDefaultToolkit().getSystemClipboard(); | |
| cp.setContents(st, this); | |
| } | |
| /** | |
| * Legge il testo dalla clipboard di sistema | |
| */ | |
| public String fromClipboard() | |
| { | |
| String contenuto = null; | |
| Clipboard cp = Toolkit.getDefaultToolkit().getSystemClipboard(); | |
| Transferable contents = cp.getContents(null); | |
| boolean hasTransferableText = (contents != null) && contents.isDataFlavorSupported(DataFlavor.stringFlavor); //Se c'è il contenuto ed è una stringa | |
| if (hasTransferableText) | |
| { | |
| try | |
| { | |
| contenuto = (String)contents.getTransferData(DataFlavor.stringFlavor); | |
| } | |
| catch(Exception e){} | |
| } | |
| return contenuto; | |
| } | |
| public void lostOwnership(Clipboard clip, Transferable tr){} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Il mouse trema | |
| * | |
| * | |
| * Autore: Antonio Bianco | |
| * Versione: |0| | |
| */ | |
| import java.awt.Dimension; | |
| import java.awt.Toolkit; | |
| import java.awt.Robot; // Controlla il mouse | |
| import java.awt.MouseInfo; // Leggi le informazioni del mouse | |
| import java.awt.PointerInfo; | |
| import java.awt.Point; | |
| import java.util.Random; | |
| public class Parkinson extends Thread | |
| { | |
| // instance variables - replace the example below with your own | |
| private int maxX; | |
| private int maxY; | |
| private int raggio; | |
| private Robot r; | |
| private boolean scassaLePalle; | |
| private JClipboard clipboard; | |
| public static void main(String args[]) | |
| { | |
| new Parkinson(); | |
| } | |
| /** | |
| * Constructor for objects of class Parkinson | |
| */ | |
| public Parkinson() | |
| { | |
| super("Parkinson"); | |
| try | |
| { | |
| r = new Robot(); | |
| scassaLePalle = true; | |
| clipboard = new JClipboard(); | |
| clipboard.toClipboard(""); | |
| Dimension dimensioniSchermo = Toolkit.getDefaultToolkit().getScreenSize(); // Legge le dimensioni dello schermo | |
| maxX = dimensioniSchermo.width - 1; | |
| maxY = dimensioniSchermo.height - 1; | |
| raggio = 5; | |
| } | |
| catch (Exception e) | |
| { | |
| System.out.println("Impossibile inizializzare la classe Robot.\nProkramma kapùtt"); | |
| System.exit(1); | |
| } | |
| this.start(); | |
| } | |
| public void run() | |
| { | |
| while(scassaLePalle) | |
| { | |
| try | |
| { | |
| // Legge la posizione attuale del mouse | |
| PointerInfo info = MouseInfo.getPointerInfo(); | |
| Point punto = info.getLocation(); | |
| Random adCapocchiam = new Random(); | |
| int x = (int)punto.getX() + adCapocchiam.nextInt(raggio+1)-(raggio/2); | |
| int y = (int)punto.getY() + adCapocchiam.nextInt(raggio+1)-(raggio/2); | |
| r.mouseMove(x, y); | |
| // Esce dall'applicazione | |
| if (clipboard.fromClipboard().equals("Geek rulez")) System.exit(0); | |
| Thread.sleep(50); | |
| } | |
| catch(Exception e) | |
| { | |
| // Nope | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment