{"id":9,"date":"2016-02-09T15:19:59","date_gmt":"2016-02-09T13:19:59","guid":{"rendered":"http:\/\/ksquared.de\/blog\/?p=9"},"modified":"2016-02-10T23:55:01","modified_gmt":"2016-02-10T21:55:01","slug":"java-global-system-hook","status":"publish","type":"post","link":"https:\/\/kra.lc\/blog\/2016\/02\/java-global-system-hook\/","title":{"rendered":"Java &#8211; Global (low level) Keyboard \/ Mouse Hook"},"content":{"rendered":"<p>About <em>five years<\/em> ago I <a href=\"https:\/\/kra.lc\/blog\/2011\/07\/java-global-system-hook-old\/\">started this blog<\/a> by picking up an idea of <a href=\"http:\/\/jotschi.de\/\">Johannes Sch&uuml;th (Jotschi)<\/a> about a global keyboard and mouse listener for Java. Today I am very happy to announce the next major version of the library now available <a href=\"https:\/\/github.com\/kristian\/system-hook\" target=\"_blank\"><strong>on GitHub<\/strong><\/a>!<\/p>\n<p><!--more--><\/p>\n<p align=\"center\"><a href=\"https:\/\/github.com\/kristian\/system-hook\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kra.lc\/blog\/wp-content\/uploads\/2016\/02\/system-hook-logo.png\" alt=\"system-hook-logo\" width=\"280\" height=\"210\" class=\"alignnone size-full wp-image-562\" \/><\/a><\/p>\n<p>Keyboard and mouse events in Java only work, if the registered component is in focus. For example, in case a window looses its focus (e.g. when minimized), it stops receiving any more events. Through a low-level system-wide hook it&#8217;s possible to deliver those events regardless. You&#8217;ll find all sources of the latest release, as well as binary bundles \/ prepackaged Java archives (JAR) on the <a href=\"https:\/\/github.com\/kristian\/system-hook\" target=\"_blank\">GitHub project page<\/a>.<\/p>\n<p><a href=\"https:\/\/kra.lc\/blog\/2011\/07\/java-global-system-hook-old\/\">The old post<\/a> describes all changes I did to the <a href=\"http:\/\/www.jotschi.de\/technik\/2008\/01\/06\/java-global-keyboard-hook-jni.html\" target=\"_blank\">initial version<\/a> by Johannes (Jotschi). For the new major release I again reworked nearly every part of the library, to make it more stable and versatile. Here is what I did:<\/p>\n<ul>\n<li>Optimized the native library C code, fixed bugs and removed all parts requireing a C++ compiler in the first place.<\/li>\n<li>Renamed the event classes and listener interfaces and prepended <code>Global<\/code> to avoid conflicts with existing (Swing) event listeners.<\/li>\n<li>Added support for <code>mouseWheel<\/code> events to the <code>GlobalMouseListener<\/code>.<\/li>\n<li>Again allowed negative &quot;out of bounds&quot; values for <code>GlobalMouseEvents<\/code>, to also track the mouse pointer off screen (e.g. on multi-monitor setups).<\/li>\n<li>Improved the threading concept and implemented a native error handling. The <code>GlobalKeyboardHook<\/code> and <code>GlobalMouseHook<\/code> constructors will now throw a <code>UnsatisfiedLinkError<\/code> if the native libraries can not be loaded or a <code>RuntimeException<\/code> in case hooking fails.<\/li>\n<li>All the code has been moved to <a href=\"https:\/\/github.com\/kristian\/system-hook\" target=\"_blank\">GitHub<\/a> and binaries are now beeing continuously built by <a href=\"https:\/\/ci.appveyor.com\/project\/kristian\/system-hook\" target=\"_blank\">AppVeyor<\/a>. Feel free to contribute on GitHub!<\/li>\n<\/ul>\n<p>(Again) Last but not least, please share your ideas and problems in the comments. I will try to enhance the Global Keyboard \/ Mouse Hook based on your feedback. For the next release let&#8217;s see if we can get Linux and \/ or Mac OSX support going.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>About five years ago I started this blog by picking up an idea of Johannes Sch&uuml;th (Jotschi) about a global keyboard and mouse listener for Java. Today I am very happy to announce the next major version of the library now available on GitHub!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[238,237,11,5,6,16,8,13,235,236,15,9,14,7,12,10,17],"class_list":["post-9","post","type-post","status-publish","format-standard","hentry","category-release","tag-event","tag-global","tag-hook","tag-java","tag-jni","tag-jotschi","tag-keyboard","tag-keyhook","tag-listener","tag-listeners","tag-low-level","tag-mouse","tag-mousehook","tag-native","tag-syshook","tag-system","tag-windows"],"_links":{"self":[{"href":"https:\/\/kra.lc\/blog\/wp-json\/wp\/v2\/posts\/9","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kra.lc\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kra.lc\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kra.lc\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kra.lc\/blog\/wp-json\/wp\/v2\/comments?post=9"}],"version-history":[{"count":78,"href":"https:\/\/kra.lc\/blog\/wp-json\/wp\/v2\/posts\/9\/revisions"}],"predecessor-version":[{"id":565,"href":"https:\/\/kra.lc\/blog\/wp-json\/wp\/v2\/posts\/9\/revisions\/565"}],"wp:attachment":[{"href":"https:\/\/kra.lc\/blog\/wp-json\/wp\/v2\/media?parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kra.lc\/blog\/wp-json\/wp\/v2\/categories?post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kra.lc\/blog\/wp-json\/wp\/v2\/tags?post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}