I am trying to write a program which detects "idle" status but I don't see the problem in my code. Could someone help me please with an useful tip? Here's my code:
package idlestatus;
import java.awt.MouseInfo;
public class Idlestatus {
public static void main(String[] args) throws InterruptedException {
Integer firstPointX = MouseInfo.getPointerInfo().getLocation().x;
Integer firstPointY = MouseInfo.getPointerInfo().getLocation().y;
Integer afterPointX;
Integer afterPointY;
while (true) {
Thread.sleep(10000);
afterPointX = MouseInfo.getPointerInfo().getLocation().x;
afterPointY = MouseInfo.getPointerInfo().getLocation().y;
if (firstPointX == afterPointX && firstPointY == afterPointY) {
System.out.println("Idle status");
} else {
System.out.println("(" + firstPointX + ", " + firstPointY + ")");
}
firstPointX = afterPointX;
firstPointY = afterPointY;
}
}
}
Aucun commentaire:
Enregistrer un commentaire