LowLevelKeyboardHook hangs after 1-2 days of constant key events

42 views
Skip to first unread message

ansgar....@gmail.com

unread,
May 2, 2014, 5:38:50 AM5/2/14
to jniwrapp...@teamdev.com
Hello,

I am using a slightly adapted version of the LowLevelKeyboardHookSample to consume keyboard-events in my application (see attachement).

Approx. after 1-2 days of constant execution (every 30 seconds a sequence of 13 chars) the keyboard hook stops to produce new events. 

When looking at it in the debugger, it hangs in native code (see screenshot). 

Do you have any hint how to resolve the issue? 

It was used with Winpack from the latest stable JxBrowser of the 3-line (ftp://ftp.teamdev.com/updates/jxbrowser-3.4.76.zip).
The OS is Windows 7 64 bit, the JVM is 32bit Java 6.

Thanks for any help in advance
Ansgar Berhorn
KeyboardHookAdapter.java
screenshot_hook.png

Anna Dolbina

unread,
May 16, 2014, 4:00:16 AM5/16/14
to ansgar....@gmail.com, jniwrapp...@teamdev.com
Hi Ansgar Berhorn,

There is a low-level keyboard hook implementation in WinPack. You can use Hook.KEYBOARD_LL in your application to handle low-level keyboard events.

The logic of this low-level keyboard hook implementation is the same as in the sample, but the hook callback implementation differs from the one used in the sample. It it possible that this difference resolves your issue. You can take a look at LowLevelHook and LowLevelKeyboardHook classes in the WinPack sources (the sources are available in JNIWrapper distribution) to see the difference. In two words, in the callback the nCode value check is performed and the hook event is processed or ignored depending on that value. Also, CallNextHookEx function is called to prevent consuming hook events.

I've modified your sample to make it using Hook.KEYBOARD_LL. Could you please try it in your environment and let us know the results?

Also, please pay attention that I've disabled your char events handling in the sample. Please try to test the sample with and without char events handling to be sure that the cause of your issue is not in such events handling.

Sincerely,
Anna



--
You received this message because you are subscribed to the Google Groups "JNIWrapper Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jniwrapper-for...@teamdev.com.
To post to this group, send email to jniwrapp...@teamdev.com.
Visit this group at http://groups.google.com/a/teamdev.com/group/jniwrapper-forum/.
For more options, visit https://groups.google.com/a/teamdev.com/d/optout.

KeyboardHookAdapter.java

Ansgar Berhorn

unread,
May 20, 2014, 10:03:23 AM5/20/14
to Anna Dolbina, jniwrapp...@teamdev.com
Hello,

thanks a lot for the feedback.
In the meantime we chose another way that did not require the native keyboard hook. 
If we use the keyboard hook in another occasion, I will test it and report if the issue gets resolved.

Kind regards,
Ansgar Berhorn
Message has been deleted

Anna Dolbina

unread,
Mar 12, 2018, 8:51:00 AM3/12/18
to Anandalakshmi Narayanan, JNIWrapper Forum
Hi Vidhya,

Could you please describe how the low-level keyboard hook is used in your case?
Also, is it possible to provide a sample code that demonstrates the low-level keyboard hook usage?

Sincerely,
Anna



On Sun, Mar 11, 2018 at 11:12 PM, <anandala...@gmail.com> wrote:
Hi Ansgar Berhorn


In what other way you were able to fix the issue?
I am also facing this issue.

Thanks
Vidhya
Reply all
Reply to author
Forward
0 new messages