pkrall520 / jnativehook

Automatically exported from code.google.com/p/jnativehook
0 stars 0 forks source link

Native Hook sporadically unregisters #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Register a native hook
2. Log state of GlobalScreen.isNativeHookRegistered() throughout the program

What is the expected output? What do you see instead?

Expected Output: Once GlobalScreen.registerNativeHook() is invoked, the native 
hook should remain registered until a corresponding 
GlobalScreen.unregisterNativeHook() is invoked.

Actual Output: The log statements show the hook turning on and off by itself 
for a few milliseconds before it finally unregisters completely.

What version of the product are you using? On what operating system?

JNativeHook-1.1.4
Windows 7 64-bit

Please provide any additional information below.
<pre>
    public SpawnTimer() {
        LogUtil.log(LOGGER, Level.DEBUG, "Entering SpawnTimer() constructor");
        try {
            while(!GlobalScreen.isNativeHookRegistered()) {
                LogUtil.log(LOGGER, Level.DEBUG, "Native hook registered? " + GlobalScreen.isNativeHookRegistered());
                GlobalScreen.registerNativeHook();
                LogUtil.log(LOGGER, Level.DEBUG, "Native hook registered? " + GlobalScreen.isNativeHookRegistered());
            }
            LogUtil.log(LOGGER, Level.DEBUG, "Native hook registered? " + GlobalScreen.isNativeHookRegistered());
            GlobalScreen.getInstance().addNativeKeyListener(this);
        }
        catch(Exception e) {
            e.printStackTrace();
        }
        LogUtil.log(LOGGER, Level.DEBUG, "Native hook registered? " + GlobalScreen.isNativeHookRegistered());
        initializeTimers();
        LogUtil.log(LOGGER, Level.DEBUG, "Native hook registered? " + GlobalScreen.isNativeHookRegistered());
        JFrame frame = new JFrame();
        LogUtil.log(LOGGER, Level.DEBUG, "Native hook registered? " + GlobalScreen.isNativeHookRegistered());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        LogUtil.log(LOGGER, Level.DEBUG, "Native hook registered? " + GlobalScreen.isNativeHookRegistered());
        frame.setVisible(true);
        LogUtil.log(LOGGER, Level.DEBUG, "Native hook registered? " + GlobalScreen.isNativeHookRegistered());
        LogUtil.log(LOGGER, Level.DEBUG, "Exiting SpawnTimer() constructor");
}
</pre>

<code>
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Entering SpawnTimer() constructor
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Native hook registered? false
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Native hook registered? true
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Native hook registered? false
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Native hook registered? true
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Native hook registered? false
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Native hook registered? true
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Native hook registered? true
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Native hook registered? false
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Entering initializeTimers()
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Exiting initializeTimers()
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Native hook registered? false
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Native hook registered? false
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Native hook registered? false
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Native hook registered? false
2013-08-11 20:02:48 DEBUG SpawnTimer:19 - Exiting SpawnTimer() constructor
</code>

Original issue reported on code.google.com by jpgoh...@gmail.com on 12 Aug 2013 at 12:04

GoogleCodeExporter commented 9 years ago
I have used the library effectively in the past.  I was using an older JAR 
(which I no longer have in order to check the version of) which often caused my 
JVM to lock up and hang.  I saw the solution to switch to the latest JAR, which 
is when this phenomenon started happening.

Original comment by jpgoh...@gmail.com on 12 Aug 2013 at 12:09

GoogleCodeExporter commented 9 years ago
This actually seems very similar (if not identical) to issue number 63.

Original comment by jpgoh...@gmail.com on 14 Aug 2013 at 7:33

GoogleCodeExporter commented 9 years ago
I believe you are correct.

Original comment by a...@1stleg.com on 9 Sep 2013 at 10:43