1 message in net.java.dev.jna.usersRe: [Fwd: Re: Global keyboard Listene...
FromSent OnAttachments
rzoNov 12, 2007 10:22 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [Fwd: Re: Global keyboard Listener using JNA]Actions...
From:rzo (rz@gmx.de)
Date:Nov 12, 2007 10:22:35 pm
List:net.java.dev.jna.users

PS,

Here some interesting Links for global keyboard hook:

http://www.codeproject.com/system/KeyHook.asp http://www.codeproject.com/system/hooksys.asp http://www.codeproject.com/system/KeyLogger.asp http://www.codeguru.com/cpp/w-p/system/keyboard/article.php/c5699/

As stated:

"A global hook procedure is called in the context of all applications in the desktop, so the procedure must reside in a separate DLL from the application installing the hook procedure."

Therefore, I assume, the hook procedure cannot reside within the java code. It must be declared in a separate DLL. The keyboard events are then sent from the DLL to a Window per PostMessage. Within my contribution, I have Implemented a DummyWindow, which you may use to receive these events within your java application.

Note: most of the DLLs with these function are discovered by Virus-Scanners, which may put them in Quarantine, once they are downloaded.

Hope this helps, and please post if you got it to work.

- Ron

Michele,

I have written a Hot Key listener. You may find it on:

https://jna.dev.java.net/nonav/issues/showattachment.cgi/11/contribution.zip

See the test.Test.testHotKey() for usage.

Please note that the windows Hot Key function is implemented in such a way, that once you set a listener on the key no other process/task may use this key. Therefore this is not useful as a general key listener. It is useful if you want your java application to listen to hot keys even if your applications window is currently not the active window.

I have also started implementing a general keyboard listener which inserts a keyboard hook. However this requires the listener method to be defined in a dll. Given that I do not have a C Development (this is the reason why I love jna) I did not continue with this. However this should not be too complicated to implement.

The java code for this is found in WindowsXPKeyboard.addListner(). However it is commented out.

Regards

- Ron

Michele Croci wrote:

Hi " rzorzorzo <http://sourceforge.net/users/rzorzorzo/>",

I was trying to implement a general keyboard listener using JNA. Unfortunately the JVM always crashes, no way to solve the problem. You say you have implemented an hotkey listener. I have looked at your code in sourceforge but I haven't found the desired functionality.

Can you help me? Do you really have written a general keyboard listener?

Thank you very much.

Best Regards,