java - how to remove the logging data from JNativeHook library -
i trying use jnativehook library in project.i want simple data (e.g mouse clicked: 2) instead of long loging data jnativehook produced like:
may 31, 2015 9:39:04 pm org.jnativehook.globalscreen$nativehookthread enable info: process_button_pressed [339]: button 1 pressed 2 time(s). (293, 661)
may 31, 2015 9:39:04 pm org.jnativehook.globalscreen$nativehookthread enable
mouse clicked: 2
info: process_button_released [361]: button 1 released 2 time(s). (293, 661)
if want remove logging spam jnativehook:
// clear previous logging configurations. logmanager.getlogmanager().reset(); // logger "org.jnativehook" , set level off. logger logger = logger.getlogger(globalscreen.class.getpackage().getname()); logger.setlevel(level.off);
adding to, example. main class construct remove (almost) logging. let's detect events , print basic information.
first, have register nativehook:
globalscreen.registernativehook();
then bind listener it, example:
globalscreen.getinstance().addnativekeylistener(new yourmainclass());
and override jnativehook event methods this:
@override public void nativekeypressed(nativekeyevent e) { system.out.println(((char) e.getkeycode()) + " pressed.") }
check out: jnativehook github, find sample code (for example global mouse listener , documentation it's events.
Comments
Post a Comment