Веб-разработка
- 2 ответа
- 0 вопросов
8
Вклад в тег
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.input.KeyEvent;
import java.awt.Robot;
import java.awt.event.InputEvent;
public class Main extends Application {
Stage window;
Robot robot;
Scene scene;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
window = primaryStage;
window.setTitle("Кликер");
StackPane layout = new StackPane();
robot = new Robot();
scene = new Scene(layout, 200, 100);
window.setScene(scene);
window.show();
scene.setOnKeyTyped(new EventHandler<KeyEvent>() {
public void handle(KeyEvent ke) {
if (ke.getCharacter().equals(" "))
for (int i = 0; i < 3; i++) {
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(300);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.delay(300);
}
}
});
}
}
scene.setOnKeyTyped(new EventHandler<KeyEvent>() {
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
scene.setOnKeyReleased(new EventHandler<KeyEvent>() {
if (ke.getCode().getName().equals("F12"))