Dynamic [Dynamic]
Member
- Joined
- Aug 16, 2008
- Sythe Gold
- 0
- Messages
- 27
Well I need a color fining method, a quick one.
It also must be able to go to other colors, so let's say the first color it finds is at point 2, 2. And I want it to find the one at 100, 100. It must find point 2, 2, but then find other points like 100, 100.
I made a method myself, but it's made slow. So that's why I'm asking for help. :nuts:
Here's the method if you want to see it:
Took 20 seconds to look over at all the colors on my computer screen... Now that's slow.
I made a method myself, but it's made slow. So that's why I'm asking for help. :nuts:
Here's the method if you want to see it:
Code:
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Robot;
import java.awt.Toolkit;
public class FindColor {
public static int MaxHeight;
public static int MaxWidth;
public static int CurrentHeight;
public static int CurrentWidth;
public static long startTime = System.currentTimeMillis();
public static boolean foundColor;
public static Color acolor;
public static Robot robot;
public static void main(String[] args) throws AWTException {
robot = new Robot();
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
MaxHeight = dimension.height;
MaxWidth = dimension.width;
acolor = new Color(0, 84, 227);
while (!foundColor) {
Search_Screen();
}
}
public static void Search_Screen() {
if (!robot.getPixelColor(CurrentHeight, CurrentWidth).equals(acolor)) {
if (CurrentHeight < MaxHeight) {
CurrentHeight++;
return;
} else if (CurrentHeight >= MaxHeight) {
CurrentHeight = 0;
if (CurrentWidth < MaxWidth) {
CurrentWidth++;
}
return;
}
System.out.println("Color not found!");
System.out.println(totalTime());
} else {
robot.mouseMove(CurrentHeight, CurrentWidth);
foundColor = true;
System.out.println("Color found!");
System.out.println(totalTime());
}
}
public static String totalTime() {
long millis = System.currentTimeMillis() - startTime;
long hours = millis / 3600000;
millis -= hours * 3600000;
long minutes = millis / 60000;
millis -= minutes * 60000;
long seconds = millis / 1000;
return ("" + hours + ":" + minutes + ":" + seconds);
}
}
Took 20 seconds to look over at all the colors on my computer screen... Now that's slow.











