Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7884433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:47:56+00:00 2026-06-03T04:47:56+00:00

import java.awt.*; import java.awt.event.InputEvent; import java.awt.image.BufferedImage; public final class test { private static Robot

  • 0
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.image.BufferedImage;

public final class test
{
    private static Robot robot;
    public static boolean clickStatus;

    public static void leftClick (int R, int G, int B)
    {
            Color myColorToMatch = new Color (R, G, B);
            BufferedImage image = robot.createScreenCapture (new Rectangle (Toolkit.getDefaultToolkit ().getScreenSize ()));
            int w = image.getWidth (null);
            int h = image.getHeight (null);
            int[] rgbs = new int[w*h];
            image.getRGB (0, 0, w, h, rgbs, 0, w);
            for (int y=0; y<h; y++) {
                for (int x=0; x<w; x++) {
                      if (new Color (image.getRGB (x, y)).equals (myColorToMatch))
                               robot.mouseMove(x, y);
                               robot.mousePress (InputEvent.BUTTON1_MASK);
                               robot.mouseRelease(InputEvent.BUTTON1_MASK);
                               break;
                    }
                    break;
            }
    }        

    public static void main(String[] args)
    {
            try
            {
                    robot = new Robot();
            }
            catch(Exception Error)
            {
                    Error.printStackTrace();
            }             
            // dImp: 130,40,32 - 160,99,57 - 217,135,79
            // banker: 139, 130, 129                
            boolean botLoop = true;
            boolean bankStatus;

            while (botLoop == true)
            {
                    robot.delay (1000);
                    leftClick (96,96,98);
            }
    }
}

But there’s a problem and I don’t know how to fix it. The bot will just Keep clicking every second where ever the mouse is and not go over to/click the desired pixel.
Could someone please help me with this? I can’t find the error

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:47:57+00:00Added an answer on June 3, 2026 at 4:47 am

    You do not have brackets around the mousePress and Release so regardless of the color it still presses the mouse, and some other issues…

     import java.awt.Color;
    import java.awt.Rectangle;
    import java.awt.Robot;
    import java.awt.Toolkit;
    import java.awt.event.InputEvent;
    import java.awt.image.BufferedImage;
    
    public final class fff {
        private static Robot robot;
        public static boolean clickStatus;
    
        public static void leftClick(int R, int G, int B) {
            Color myColorToMatch = new Color(R, G, B);
            BufferedImage image = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
            int w = image.getWidth(null);
            int h = image.getHeight(null);
            int[] rgbs = new int[w * h];
            image.getRGB(0, 0, w, h, rgbs, 0, w);
            for (int y = 0; y < h; y++) {
                for (int x = 0; x < w; x++) {
                    if (new Color(image.getRGB(x, y)).equals(myColorToMatch)) {
                        robot.mouseMove(x, y);
                        robot.mousePress(InputEvent.BUTTON1_MASK);
                        robot.mouseRelease(InputEvent.BUTTON1_MASK);
                        break;
                    }
                }
            }
        }
    
        public static void main(String[] args) {
            try {
                robot = new Robot();
            } catch (Exception Error) {
                Error.printStackTrace();
            }
            // dImp: 130,40,32 - 160,99,57 - 217,135,79
            // banker: 139, 130, 129
            boolean botLoop = true;
            while (botLoop == true) {
                robot.delay(1000);
                leftClick(0, 0, 0);
                break; //no lop
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package test; import java.awt.*; import java.awt.event.*; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; import javax.swing.*; public class
My code: import java.awt.Robot; import java.awt.event.KeyEvent; import java.util.Scanner; public class main { public static
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TestSwingListeners1 { private static int cnt1;
import java.awt.*; import java.awt.image.ImageObserver; import javax.swing.*; public class CharacterMove { CharacterCollision CharacterCollision; public static
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class test extends JFrame implements MouseListener {
import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.lang.Thread; public class Lthread extends JPanel{ private
import java.awt.*; import javax.swing.*; import java.awt.event.*; public class displayFullScreen extends JFrame { private JLabel
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Gui extends JFrame { private JFrame
import java.io.*; import javax.swing.*; import java.awt.event.*; import java.awt.*; import java.text.DecimalFormat; public class Final extends
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class File { private JFrame frame1; private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.