robot class not working

I need to make a macro with the robot class that draws a picture in a paint program. For each color in the image (256 colors total) it should change the paint color and drawing each 2x2 pixel that's that color. I made the program and it works correctly for about an hour, but then it starts slowing down a LOT, entering the wrong color codes, and drawing single pixels instead of 2x2.

Here is the code for changing the color:

robot.mouseMove (535, 504);

robot.mousePress (InputEvent.BUTTON1_MASK);

robot.mouseRelease (InputEvent.BUTTON1_MASK);

robot.mouseMove (568, 410);

robot.mousePress (InputEvent.BUTTON1_MASK);

robot.mouseRelease (InputEvent.BUTTON1_MASK);

robot.mousePress (InputEvent.BUTTON1_MASK);

robot.mouseRelease (InputEvent.BUTTON1_MASK);

for (i = 0; i < 6; i++)

{

robot.keyPress (color.toUpperCase ().charAt (i));

}

robot.keyPress (KeyEvent.VK_ENTER);

robot.keyRelease (KeyEvent.VK_ENTER);

Here is the code for drawing each pixel:

robot.mouseMove (415 + (w * 2), 185 + (h * 2) - 1);

robot.mousePress (InputEvent.BUTTON1_MASK);

robot.mouseMove (415 + (w * 2), 185 + (h * 2) + 1);

robot.delay (100);

robot.mouseRelease (InputEvent.BUTTON1_MASK);

Does anyone know why the robot stops working after about an hour?

[1451 byte] By [gfgguiosdisfnjma] at [2007-11-27 8:37:23]
# 1

I'll guess that this might have something to do with it:

for (i = 0; i < 6; i++)

{

robot.keyPress (color.toUpperCase ().charAt (i));

//need to release the key!

robot.keyRelease (color.toUpperCase ().charAt (i));

}

Also, about your code to draw one pixel: it draws three pixels in a vertical line, at least in my paint program.

RATiXa at 2007-7-12 20:34:42 > top of Java-index,Java Essentials,Java Programming...