机器人类-Java import java.awt.*; 导入java.awt.event.InputEvent; 导入java.awt.image.buffereImage; 公开期末考试 { 私人静态机器人; 公共静态状态; 公共静态无效左键单击(int R、int G、int B) { 颜色颜色匹配=新颜色(R、G、B); BuffereImage=robot.createScreenCapture(新矩形(Toolkit.getDefaultToolkit().getScreenSize()); int w=image.getWidth(null); int h=image.getHeight(null); int[]rgbs=新int[w*h]; image.getRGB(0,0,w,h,rgbs,0,w); 对于(int y=0;y
鼠标按下和释放时没有括号,因此无论颜色如何,它仍会按下鼠标,以及其他一些问题机器人类-Java import java.awt.*; 导入java.awt.event.InputEvent; 导入java.awt.image.buffereImage; 公开期末考试 { 私人静态机器人; 公共静态状态; 公共静态无效左键单击(int R、int G、int B) { 颜色颜色匹配=新颜色(R、G、B); BuffereImage=robot.createScreenCapture(新矩形(Toolkit.getDefaultToolkit().getScreenSize()); int w=image.getWidth(null); int h=image.getHeight(null); int[]rgbs=新int[w*h]; image.getRGB(0,0,w,h,rgbs,0,w); 对于(int y=0;y,java,awtrobot,Java,Awtrobot,鼠标按下和释放时没有括号,因此无论颜色如何,它仍会按下鼠标,以及其他一些问题 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
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);
}
}
}
导入java.awt.Color;
导入java.awt.Rectangle;
导入java.awt.Robot;
导入java.awt.Toolkit;
导入java.awt.event.InputEvent;
导入java.awt.image.buffereImage;
公开期末班{
私人静态机器人;
公共静态状态;
公共静态无效左键单击(int R、int G、int B){
颜色颜色匹配=新颜色(R、G、B);
BuffereImage image=robot.createScreenCapture(新矩形(Toolkit.getDefaultToolkit().getScreenSize());
int w=image.getWidth(null);
int h=image.getHeight(null);
int[]rgbs=新int[w*h];
getRGB(0,0,w,h,rgbs,0,w);
对于(int y=0;y
鼠标按下和释放时没有括号,因此无论颜色如何,鼠标仍会按下,以及其他一些问题
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);
}
}
}
导入java.awt.Color;
导入java.awt.Rectangle;
导入java.awt.Robot;
导入java.awt.Toolkit;
导入java.awt.event.InputEvent;
导入java.awt.image.buffereImage;
公开期末班{
私人静态机器人;
公共静态状态;
公共静态无效左键单击(int R、int G、int B){
颜色颜色匹配=新颜色(R、G、B);
BuffereImage image=robot.createScreenCapture(新矩形(Toolkit.getDefaultToolkit().getScreenSize());
int w=image.getWidth(null);
int h=image.getHeight(null);
int[]rgbs=新int[w*h];
getRGB(0,0,w,h,rgbs,0,w);
对于(int y=0;y
for的内部for循环旁边的无条件“break”是什么?用于结束for循环。如果我不添加它,它将继续单击。它将穿过我的屏幕大小1600x900,但外部for循环将仅在y=0时运行,然后断开。对吗?内部If块只有一行,没有花括号while(botLoop==true)
是,顺便说一句,相当于while(botLoop)
和while(((botLoop==true)==true)==true)
什么是无条件的“中断”在for?的内部for循环旁边结束for循环。如果我不添加它,它将继续单击。它将通过我的屏幕大小1600x900,但外部for循环将仅在y=0时运行,然后中断。对吗?内部If块只有一行,没有花括号,而(botLoop==true)
是,顺便说一句,相当于while(botLoop)
和to而(((botLoop==true)==true)==true)