1

I want to make a custom keyboard to control the CNC machine. The keyboard on the machine itself was damaged and my idea is to replace it with a touch screen. I made a program that looks similar to a keyboard, the keys I click work but only within my program.

How do I pass the clicks on my virtual keyboard to Windows / another program?

Here is UI my UI

Key listeners

@FXML
void clickOnZero(TouchEvent event) {
    KeyEvent press = new KeyEvent(zero_btn, zero_btn, KeyEvent.KEY_PRESSED, "", "", KeyCode.DIGIT0, false, false, false, false);
    shift_btn.fireEvent(press);
}

EDIT

To be a little clearer. My program is a keyboard and separately is the original program for CNC. I would split the screen in two and it would work that way. My problem is how to click on a key in my program to simulate the keystroke on an actual keyboard so that the CNC program can see it

  • The `Robot` or `FXRobot` class may be the perfect solution here because it works system wide. For examples see [Robot and keyPress](https://stackoverflow.com/questions/18165493/robot-and-keypress) and [Use a robot to type characters in Java](https://stackoverflow.com/questions/6641962/use-a-robot-to-type-characters-in-java) – sorifiend Jun 27 '22 at 21:14
  • Without knowing the interfaces and protocols the other machine provides for remote communication and how to make use of them, I don't think this can be answered, even then I think it is unlikely to be answerable in the StackOverflow context. If you are lucky, and sorifend's robot solution works for you, then, great, if not, well, not so great ;-) – jewelsea Jun 27 '22 at 21:52
  • I tried like this FXRobot robot = FXRobotFactory.createRobot(background.getScene()); robot.keyPress(javafx.scene.input.KeyCode.WINDOWS); But windows can't see that click – Armin Brkić Jun 28 '22 at 14:34

0 Answers0