2 messages in net.java.dev.jna.usersRe: [jna-users] Re: [Fwd: Re: Global ...
FromSent OnAttachments
rzoNov 19, 2007 12:09 pm 
Timothy WallNov 19, 2007 12:59 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: [jna-users] Re: [Fwd: Re: Global keyboard Listener using JNA]Actions...
From:rzo (rz@gmx.de)
Date:Nov 19, 2007 12:09:39 pm
List:net.java.dev.jna.users

Timothy,

Thanks for the clarification. I was not aware of this. What do you think is the best way for building a global key listener, using WH_KEYBOARD_LL or WH_KEYBOARD ? What is the advantage/disadvantage of each ? Most examples I found on the internet use WH_KEYBOARD.

Concerning the bug you have found with WH_KEYBOARD_LL. Have you already checked the changes into subversion ?

- Ron

On Nov 13, 2007, at 1:22 AM, rzo wrote:

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."

The exception here is low-level keyboard and mouse hooks, which do *not* have to reside in a DLL. From MSDN:

However, the WH_KEYBOARD_LL hook is not injected into another process. Instead, the context switches back to the process that installed the hook and it is called in its original context. Then the context switches back to the application that generated the event.

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.

Thanks for the contribution!