Changeset 92
- Timestamp:
- Apr 1, 2010, 8:45:49 PM (15 years ago)
- Location:
- java-automator
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
java-automator/.project
r87 r92 7 7 <buildSpec> 8 8 <buildCommand> 9 <name>org.eclipse.wst.common.project.facet.core.builder</name> 10 <arguments> 11 </arguments> 12 </buildCommand> 13 <buildCommand> 9 14 <name>org.eclipse.jdt.core.javabuilder</name> 10 15 <arguments> … … 14 19 <natures> 15 20 <nature>org.eclipse.jdt.core.javanature</nature> 21 <nature>org.eclipse.wst.common.project.facet.core.nature</nature> 16 22 </natures> 17 23 </projectDescription> -
java-automator/src/nl/rickvanderzwet/farmville/Automator.java
r87 r92 35 35 } 36 36 37 private static void moveMouse(Direction direction) throws InterruptedException { 38 moveMouse(direction, 200); 39 } 40 41 private static void moveMouse(Direction direction, Integer sleep_msec) throws InterruptedException { 42 /* Relocate to next field */ 43 PointerInfo pointer = MouseInfo.getPointerInfo(); 44 45 Integer XMOVE = 24; 46 Integer YMOVE = 11; 47 48 Integer x = pointer.getLocation().x; 49 Integer y = pointer.getLocation().y; 50 51 switch (direction) { 52 case UP: 53 bot.mouseMove(x - XMOVE, y - YMOVE); 54 break; 55 case DOWN: 56 bot.mouseMove(x + XMOVE, y + YMOVE); 57 break; 58 case LEFT: 59 bot.mouseMove(x - XMOVE, y + YMOVE); 60 break; 61 case RIGHT: 62 bot.mouseMove(x + XMOVE, y - YMOVE); 63 break; 64 } 65 Thread.sleep(sleep_msec); 66 } 67 37 68 /** 38 69 * @param args … … 46 77 PointerInfo pointer = null; 47 78 randomGenerator = new Random(); 48 // Allow time to focus firefox window79 // Allow time to focus Firefox window 49 80 Thread.sleep(2000); 50 81 … … 57 88 */ 58 89 59 Boolean press_mouse = false; 60 Integer farm_size_y = 4; 61 Integer farm_size_x = 19; 90 /* Constants */ 91 Boolean press_mouse = true; 92 Integer farm_size_y = 6; 93 Integer farm_size_x = 20; 62 94 /* 0 = up, 1 = down, 2 = left, 3 = right */ 63 Direction direction = Direction.UP;64 95 65 96 if (press_mouse) { 66 97 pressMouse(); 67 98 } 99 100 Direction direction = Direction.UP; 101 68 102 // Save the mouse button :-) 69 103 for (int i = 0; i < farm_size_y; i++) { … … 76 110 77 111 78 /* Too difficult to diffentiate, try larger parts */112 /* Too difficult, try larger parts */ 79 113 Color p = bot.getPixelColor(x, y); 80 114 System.out.println("Pixel color R:" + p.getRed() + ",G:" + 81 115 p.getGreen() + ",B:" + p.getBlue()); 82 83 /* Relocate to next field */84 switch (direction) {85 case UP:86 bot.mouseMove(x - 24, y - 12);87 break;88 case DOWN:89 bot.mouseMove(x + 24, y + 12);90 break;91 case LEFT:92 bot.mouseMove(x - 24, y + 12);93 break;94 case RIGHT:95 bot.mouseMove(x + 24, y - 12);96 break;97 }98 116 99 Thread.sleep(100);100 101 117 if (press_mouse) { 102 118 pressMouse(); 103 119 } 120 moveMouse(direction); 104 121 } 122 123 moveMouse(Direction.LEFT); 105 124 125 if (direction == Direction.UP) { 126 direction = Direction.DOWN; 127 } else { 128 direction = Direction.UP; 129 } 106 130 } 107 131 } catch (AWTException e) {
Note:
See TracChangeset
for help on using the changeset viewer.