Changeset 108
- Timestamp:
- Apr 13, 2010, 8:03:11 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java-automator/src/nl/rickvanderzwet/farmville/ScreenRecognition.java
r104 r108 9 9 import java.awt.*; 10 10 import java.awt.event.*; 11 import java.awt.geom.Point2D;12 11 import java.awt.image.BufferedImage; 13 import java.awt.image.Raster;14 12 import java.awt.image.RasterFormatException; 15 import java.io.IOException;16 13 17 14 18 15 public class ScreenRecognition extends Frame implements ActionListener { 16 /** 17 * 18 */ 19 private static final long serialVersionUID = -6742715532913330783L; 19 20 static int mouseSurround = 120; 20 21 Image image; … … 25 26 26 27 static boolean freezeImage = false; 28 static boolean mouseClickEnabled = true; 27 29 28 30 private static void pressMouse() throws InterruptedException { 29 bot.mousePress(InputEvent.BUTTON1_MASK); 30 bot.mouseRelease(InputEvent.BUTTON1_MASK); 31 if (mouseClickEnabled) { 32 bot.mousePress(InputEvent.BUTTON1_MASK); 33 bot.mouseRelease(InputEvent.BUTTON1_MASK); 34 } 31 35 32 36 } 33 37 34 38 public ScreenRecognition() { 35 setTitle(" Image demoExample");39 setTitle("Screen Recognition Example"); 36 40 37 41 Panel buttons = new Panel(); … … 40 44 Button greenButton = new Button("Green"); 41 45 redButton.setName("redButton"); 46 redButton.setLabel("Freeze Screen"); 42 47 redButton.addActionListener(this); 43 48 blueButton.setName("blueButton"); 49 blueButton.setLabel("Stop clicking"); 44 50 blueButton.addActionListener(this); 45 51 buttons.add(redButton); … … 69 75 } 70 76 freezeImage = !freezeImage; 77 } else if (c.getName() == "blueButton") { 78 mouseClickEnabled = !mouseClickEnabled; 79 if (mouseClickEnabled) { 80 ((Button) c).setLabel("Stop clicking"); 81 } else { 82 ((Button) c).setLabel("Start clicking"); 83 } 71 84 } 72 85 } … … 115 128 if (pixelTreshold == 0) { 116 129 pressMouse(); 117 System.out.println("Button Click ");130 System.out.println("Button Click at [" + mouse.x + "," + mouse.y + "]"); 118 131 } 119 132
Note:
See TracChangeset
for help on using the changeset viewer.