高级屏幕抓取?

时间:2013-06-07 00:41:58

标签: java image screen screen-scraping processing

我在yahoo,pogo等游戏中看到了几个游戏机器人网站,你用什么/如何编写检测屏幕上项目的软件?例如,在java中,你如何检测动态游戏窗口并识别正方形块正在发挥作用(例如在俄罗斯方块中)..你如何从屏幕上的项目跳跃到让软件识别它? ?

1 个答案:

答案 0 :(得分:0)

首先,在Java / Processing中,您通常会在网站中嵌入Applet。 Java Frame类为您提供屏幕XY起点(左上角,即0,0)和屏幕边界(右下角,即'width'和'height')。这类似于Python,JavaScript和任何其他软件 - 网络或其他 - 使用'画布'即。一个屏幕。

其次,无论你绘制到屏幕上的是你自己的创作 - 所以你以编程方式访问你绘制的任何内容的XY坐标。这可以通过全局变量来控制,或者更好的是,使用返回坐标的方法的类的Object。

示例:

Ball ball;

void setup() {
  size(640, 480);
  smooth();

  ball = new Ball(width/2, height/2, 60);
}

void draw() {
  background(0, 255, 0);
  ball.move();
  ball.boundsDetect();
  ball.draw();

  println("The X Position is " + getX() + " and the Y Position is " + getY());
}

class Ball {

  float x, y;
  float xSpeed = 2.8;
  float ySpeed = 2.2;
  int bSize, bRadius;
  int xDirection = 1;
  int yDirection = 1;

  Ball(int _x, int _y, int _size) {
    x = _x;
    y = _y;
    bSize = _size;
    bRadius = bSize/2;
  } 

  void move() {
    x = x + (xSpeed * xDirection);
    y = x + (ySpeed * yDirection);
  }

  void draw() {
    fill(255, 0, 0);
    stroke(255);
    ellipse(x, y, bSize, bSize); 
    println("here");
  }

  void boundsDetect() {
    if (x > width - bRadius || x < bRadius) {
      xDirection *= -1;
    }
    if (y > height - bRadius || y < bRadius) {
      yDirection *= -1;
    }

  }

  float getX() {
    return x;
  }

  float getY() {
    return y;
  }

}