B4J Library jNativeHookB4J for intercepting system input events

JakeBullet70

Well-Known Member
Licensed User
Longtime User

ThRuST

Well-Known Member
Licensed User
Longtime User
NativeHook v2.1.0 beta is just showing a white empty pane with a waiting icon, and needs to be closed.
This library needs to be updated. It does not work on Windows 10 x64 with the latest Java JRE 1.8.0_111.
 

stevel05

Expert
Licensed User
Longtime User
There seems to be a problem with the NativeMouseClicked Method when I consume an event, it's almost as if the released phase is not being processed. Mouse control is not consistent after the first captured event.

It seems to work as expected if I use the MousePressed and MouseReleased methods instead. Modified demo attached.

Win10 JDK 1.8.0_71
 

Attachments

  • NHUI.zip
    1.3 KB · Views: 510

ThRuST

Well-Known Member
Licensed User
Longtime User
Steve, do you know how to use mouse buttons with jNativeHookB4J? I would like to see a simple example to get started.
Yesterday I bought a Logitech G300S gaming mouse and want to add support for it in my project. I recommend you do as well as 9 programmable buttons will open for new ways to interact with windows applications. Some buttons can use keyboard and combinations and be programmed into the mouse internal memory by Logitech gaming application that stays in the taskbar. You can use any of their SDKs to access the leds and stuff and to change the keyboard char/combinations. The mouse driver exists for both Windows and Mac (all versions), so there will be plenty of opportunities to write sophisticated applications with gaming mouse support.
A simple source code example how to access the mouse buttons would be great, so that I can implement mouse button support in my project.
The thing is that I want to access the mouse buttons from outside the form, so that I can associate it with contextmenus and useful stuff.
Make sure you buy the Logitech G300S gaming mouse it's the perfect mouse not only for gaming, my idea is that it will be awesome in applications.
The potential is endless so check it out and then tell me how thanful you are that I recommended it so you can be a master a jnativehookb4j
 

stevel05

Expert
Licensed User
Longtime User
All I know so far is in the app attached to the post above. Unfortunately there is not going to be a 'simple' example as dealing with this is going to be quite complex by it's nature. There are a number of things that will have to be done in an unconventional manner to get it to be useful for what you are after. if I get it working reliably I'll share the code.
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Is it difficult to write a 'simple mouse library' that access the native Java mouse mouseclick event and allow something to do with it?
What is the complexity all about by accessing multiple mouse buttons in java? I am thinking outside the native hook by asking this.
 

ThRuST

Well-Known Member
Licensed User
Longtime User
I'm not sure, but if this might be of any help to put together a mouse library for mouseclicks outside the form, I am willing to donate money to the one who can help me. because it's vital that I progress with my B4J project. Here goes
You can add an event filter to the scene with addEventFilter(). This will be called before the event is consumed by any child controls. Here's what the code for the event filter looks like.


Native Java
B4X:
scene.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
    @Override
    public void handle(MouseEvent mouseEvent) {
        System.out.println("mouse click detected! " + mouseEvent.getSource());
    }
});

Good luck.
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Steve, It depends on threading library I don't have it, but I have the others. Do you mind posting that library here?
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Steve, it seems to works very well. Did you put this together by the time I asked the question? Guess if I am happy to see this, words cannot express how thankful I am this means alot to me. You will be the first to beta test my project once I have come further with my work. Even in that case I only can access one mouse button that will be good enough to make it extremely useful. And in that case I might be able to support all of the buttons, WOW. Go buy the Logitech G300S gaming mouse all of you, and especially you Steve I was about to start a new WPF project in Visual studio 2015, but there's no need for that now. I should implement your nice text colour routine as well. Since you helped me to learn to use the tableview control with SQLite I will be able to implement that as well as mouse support.
The last thing I need to ask for is that you strip out the printing routine from the text colouring example and leave out the very core for text highlighting so I can add it to a view in my project. After that I will let you see my project and I will donate money for your help and code. I think you deserve some appreciation from your work. Can I reach you somewhere else than from this forum? I had a bad day at the business course today, but man did you make up for that. Thanks for your help I really appreciate it. Now I can go back to work on my B4J Mindcraft project. I have tested in on my Macbook and it runs perfectly. I'll let you know if your mouse support works on my Mac. I cannot see why it shouldn't, but I look forward to try that.



Steve made it happen
 

Cableguy

Expert
Licensed User
Longtime User
Hi, trying to implement this using the latest release JNativeHook v2.1.0 but it seems to not be 100% compatible with your lib.

Using it on Main module works just fine, but I can't get it to work on Class Modules.
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Just to make it easier for the code monsters to help you
Which version of JDK are you using? This seems more and more relevant the more time that passes..
 

Cableguy

Expert
Licensed User
Longtime User
I'm using OpenJDK 11 but the error message clearly states that it couldn't find the class I initialized it in.
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Sorry we need to be more precise of version. Open-Java v11.0.1 I assume? Darn I should add this option to Athena document templates. It's extremely relevant to JavaFX.
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Did JakeBullet wrap up this lib? PM him to answer here.
 

Roycefer

Well-Known Member
Licensed User
Longtime User
The first post in this thread says that the B4J library is built for version 2.0.2 of the jNativeHook library. You shouldn't assume that newer versions of the jNativeHook library will work.
 

Cableguy

Expert
Licensed User
Longtime User
My post was more in the sense of "asking" for a possible update of this lib since it's (almost) impossible to find the original version of this.
Also, using a 3 years old wrapper, when the last lib update is less that a few months old, is like using a pixel 3 with android 4!
 

Roycefer

Well-Known Member
Licensed User
Longtime User
It's not almost impossible to find the version 2.0.2 of the JNativeHook library. It's exactly as easy as it was when the jNativeHookB4J library was first released. The library is at the link provided in the first post.

Is there some new feature in version 2.1.0 that you need that isn't in version 2.0.2?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…