Comments (4)
Can you provide steps or code to duplicating the issue?
from jnativehook.
Sure.
assume the following code:
public class MouseHook
{
/** prints the license terms and turns off logger output
**/
private void printMessage(){
// Clear previous logging configurations.
LogManager.getLogManager().reset();
// Get the logger for "org.jnativehook" and set the level to off.
Logger logger =
Logger.getLogger(GlobalScreen.class.getPackage().getName());
logger.setLevel(Level.OFF);
try {
GlobalScreen.registerNativeHook();
GlobalScreen.unregisterNativeHook();
} catch (NativeHookException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void getMouseClick(){
try{
GlobalScreen.registerNativeHook();
GlobalMouseListener listener = new GlobalMouseListener();
GlobalScreen.getInstance().addNativeMouseListener(listener);
while (!listener.isDone()){ /// wait for a click
Thread.sleep(50);
}
NativeMouseEvent mouseEvent = listener.getLastEvent();
GlobalScreen.unregisterNativeHook();
/// get coordinates
// do stuff
}
catch (NativeHookException ex) {
System.err.println("There was a problem registering the
native hook.");
System.err.println(ex.getMessage());
System.exit(1);
}
catch (InterruptedException e) {
e.printStackTrace();
} catch (AWTException e) {
e.printStackTrace();
}
}
}
first I call print message, then getMouseClick. the program exits at
registerNativeHook.
If i don't call printMessage first, it works.
If the program runs in debug mode (eclipse), it also works.
thanks,
RenΓ©
On 11/11/2014 11:27 AM, Alex Barker wrote:
Can you provide steps or code to duplicating the issue?
β
Reply to this email directly or view it on GitHub
#20 (comment).
from jnativehook.
Trunk no longer crashes but it still doesn't behave correctly. Re-registering hooks is causing the jvm to leak threads. Despite calling DetachCurrentThread, native threads are never cleaned up by the jvm O_o
This could be related, I need to do more testing:
http://stackoverflow.com/questions/20325792/java-thread-leaks-when-calling-back-from-native-thread-via-jni
https://bugs.openjdk.java.net/browse/JDK-8033696
from jnativehook.
Ok, I have a workaround in place for 1.2.0-RC3. Thanks for the report.
from jnativehook.
Related Issues (20)
- GetKeyCode() Always Returns 0 HOT 5
- GlobalKeyListener not working in windows executable file
- URI is not hierarchical
- Could you please build a new release?
- ConsoleOutput.md error?
- When packaging modular projects with jpackage, module names can't start with "app."
- Why is the NativeHookThread deliberately NOT a daemon thread? HOT 1
- Unable to extract the native library /com/github/kwhat/jnativehook/lib/windows/x86_64/JNativeHook.dll! HOT 2
- A fatal error has been detected by the Java Runtime Environment: HOT 1
- Keyboard hook notwork HOT 2
- GlobalScreen class does not implement AutoCloseable, preventing usage in try-with-resources
- GlobalScreen.postNativeEvent Not Working When Windows Screensaver Is Active
- typo in doc/Keyboard.md
- java.lang.UnsatisfiedLinkError: Unable to extract the native library
- Distinguish between virtual input and human input HOT 1
- The key combination cannot be monitored HOT 1
- How to Pause and resume keystroke events
- Keyboard event loss
- Mouse forward and back button events not fired on macos 14.5 HOT 2
- Monitoring the input of the barcode scanner may result in partial data loss HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jnativehook.