0

I have a swing Java application (A) that launches another application (B) using Runtime.getRuntime().exec() when a certain button is pressed.

Is it possible to set a certain Key Hook so that when the application (B) is open and active, it changes the buttons (for example, when you press "Q", in fact, the "H" button is pressed, and so on). And a similar situation for the mouse (for example, if "Mouse Mid" or "Mouse Wheel" is pressed, in fact another button is pressed, for example "T").

Ideally, it should work for all operating systems if possible, but Windows primarily.

Please tell me if it is possible to implement this at all, I will be glad to any advice or examples.

2
  • You need to work at the operating system level so the solution must be different for each platform, no? Commented Nov 16, 2020 at 14:44
  • @Abra Probably yes, I just never came across native functions and for me this is a new area. I read and watched a video about JNA / JNI / Jnativehook library. But in all the examples that I saw, it was only possible to catch the incoming key value. I do not know which direction to look in order to change and transfer it. Commented Nov 16, 2020 at 14:47

1 Answer 1

1

As you want to hook with operating system's low level events. It could require JNI implementation that could be complex and will require OS libraries. There is one Maven library available at Github https://github.com/kristian/system-hook

It contains required libs as mentioned in Readme.md file. I haven't tried this. Hopefully it should work.

Sign up to request clarification or add additional context in comments.

1 Comment

This is good library to catch key / mouse pressed, released and so on. But it's still not clear for me how to change incoming key to desired one?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.