Siema, mam problem chcę napisać program który będzie klikał lewym przyciskiem myszy. Napisałem program i uruchomiłem na pulpicie, klika dobrze. Jak włączę grę to nie klika, tu macie kod napiszcie co zrobiłem źle:
[code]
/*
- To change this template, choose Tools | Templates
- and open the template in the editor.
*/
package clicker;
import java.awt.Robot;
import java.awt.event.InputEvent;
/**
*
-
@Author Michał
*/
public class Main {public static void main(String[] args) {
M m=new M();
}
}
class M implements Runnable {
Thread t;
Robot r;
public M(){
t=new Thread(this);
t.start();
}
public void run() {
try {
System.out.println("go!");
Thread.sleep(5000);
while(true){
r=new Robot();
r.mousePress(InputEvent.BUTTON1_MASK);
r.delay(50);
r.mouseRelease(InputEvent.BUTTON1_MASK);
Thread.sleep(100);}
} catch (Exception ex) {}
}
}
[/code]
z góry dzięki. :)