AnsweredAssumed Answered

Spark should capture keyboard event out of Spark for idle

Question asked by hanguokai on Dec 3, 2010
Latest reply on Mar 28, 2011 by Walter Ebeling

org.jivesoftware.sparkimpl.plugin.idle.UserIdlePlugin .


This Plugin can't capture keyboard event when I am at other application (eg. Word) . So if I use other application for a long time and only use keyboard, Spark will be idle (away), but I am not away !


This problem does not appear in MSN, etc.


UserIdlePlugin use global EventQueue capture KeyEvent, this is only useful when current focus on Spark.

I know Java can't capture low level keyboard event unless use native method.


I found use JNA(Java Native Access, ) can achieve. For examples, on Windows, implements a LowLevelKeyboardProc and set this hook in system.


Attachment is a patch for UserIdlePlugin in trunk which can capture system key event on Win32. This use jna's lib (jna.jar & platform.jar ) .download link : r=12329&folderID=0 . On other os,  jna does not seem to provide support.