Java FX app: using SikuliX features in handlers freezes UI
Hey,
i am new to Java and sikuli and i do need some help.
I work with Java 8 and the Intellij IDEA.
This is my Main.java class:
package main;
import javafx.
import javafx.
import javafx.
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.
}
public static void main(String[] args) {
}
}
And this is my Controller.java:
package main;
import javafx.
import javafx.
import javafx.
import javafx.
import javafx.
import javafx.
import javafx.
import org.sikuli.
import org.sikuli.
import org.sikuli.
import org.sikuli.
import java.awt.*;
import java.awt.
import java.nio.file.Path;
import java.nio.
import java.util.
public class Controller {
public Label lbl_score;
public Button btn_startstop;
public int score = 0;
public boolean bool_isWorking= false;
public void initialize() {
//pasted this from stackoverflow
Timeline fiveSecondsWonder = new Timeline(new KeyFrame(
public void handle(ActionEvent event) {
}
}));
}
public void setBtn_
if (bool_isWorking) {
} else {
}
}
public void testFunction() {
if (bool_isWorking) {
if (bool_isWorking) {
}
if (bool_isWorking) {
}
}
public void searchforImage(
boolean found = false;
int clickPositionX = 0;
int clickPositionY = 0;
Screen s = new Screen();
try {
//searches if the image appears and creates "random" coordinations as i dont want the program to click on the exact same spot every time, but using s.click instead of s.find did not help
Path resurceDirectory = Paths.get("src", "main", "pictures");
Match m = s.find(
int x = m.x;
int y = m.y;
int v = n.x;
int w = n.y;
int k = v - x;
int g = x + 2 * k;
int o = w - y;
int u = y + 2 * o;
found = true;
} catch (FindFailed e) {
// TODO Auto-generated catch block
// e.printStackTra
}
if (found) {
}
}
//makes the mousemove less annoying
public void mousemove(int x, int y) {
if (bool_isWorking) {
int xOrig = (int) b.getX();
int yOrig = (int) b.getY();
try {
// press the left mouse button
// release the left mouse button
// move the mouse back to the original position
//avoids that the mouse gets stuck between my monitors
} catch (Exception e) {
}
}
}
}
I hope you guys can at least kinda understand my code. The problem i have is that once i run the code my UI starts to freeze while sikuli is searching for an image. Any way to work around this?
Thanks for your help!
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Julian
- Solved:
- Last query:
- Last reply:
This question was reopened
- by Julian