

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
6 messages in net.java.dev.jna.usersRe: [jna-users] Create a Block hook w...| From | Sent On | Attachments |
|---|---|---|
| Maxwell C. Xandeco | Apr 23, 2008 9:25 am | |
| Timothy Wall | Apr 23, 2008 12:13 pm | |
| Maxwell C. Xandeco | Apr 23, 2008 12:59 pm | |
| Timothy Wall | Apr 23, 2008 1:06 pm | |
| Daniel Kaufmann | Apr 23, 2008 5:55 pm | |
| Maxwell C. Xandeco | May 7, 2008 12:47 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] Create a Block hook with jna | Actions... |
|---|---|---|
| From: | Daniel Kaufmann (dani...@gmail.com) | |
| Date: | Apr 23, 2008 5:55:26 pm | |
| List: | net.java.dev.jna.users | |
As explained in MSDN http://msdn2.microsoft.com/en-us/library/ms644959(VS.85).aspx "A global hook monitors messages for all threads in the same desktop as the calling thread. ... A global hook procedure can be called in the context of any application in the same desktop as the calling thread, so the procedure must be in a separate DLL module... "
In this case you are trying to install a global hook so it must be in a dll so it can be injected into other processed. The problem with implementing this in java and jna is that no JVM might exist in the process so you might need to start one, which will probably be slow and quite a lot of resources and I think it will need native code to make this work, not just JNA. http://msdn2.microsoft.com/en-us/library/ms644959(VS.85).aspx
An easier approach is to use global hotkeys. Your window will get a message when you press certain key (might be with modifiers like Ctrl,Alt, etc. but I think it works fine even without modifiers) , and you can just ignore it. Use RegisterHotKey function for registering the hotkeys: http://msdn2.microsoft.com/en-us/library/ms646309.aspx Thanks, Daniel
----- Original Message ----- From: "Timothy Wall" <twal...@dev.java.net> To: <use...@jna.dev.java.net> Sent: Wednesday, April 23, 2008 5:07 PM Subject: Re: [jna-users] Create a Block hook with jna
Unfortunately, the code executed by WH_KEYBOARD must reside within a DLL due to the way that the windows OS accesses the callback. I don't know any more than that, since the MS docs are light on the details of exactly *why* that is the case, or what the specific software requirements are for successful callback execution. There might be a workaround, there might not.
On Apr 23, 2008, at 4:00 PM, Maxwell C. Xandeco wrote:
Timothy, I have a native app that blocks the keyboard ,but I not have the source code,I only need to process the data before calling the next hook
I found a jna example that blocks the keyboard on:
https://jna.dev.java.net/nonav/issues/showattachment.cgi/11/contribution .zip
I realized that in this example the type of hook used is WH_KEYBOARD, on KeyHook example the type used is WH_KEYBOARD_LL, i tried the following change:
hhk = lib.SetWindowsHookEx(User32.WH_KEYBOARD, keyboardHook, hMod, 0);
But don't works form me,nothing happens after register the hook.
I think that changing the type WH_KEYBOARD_LL to WH_KEYBOARD solve the problem, you have some idea of how the type WH_KEYBOARD work in the example KeyHook.
Thanks.... Maxwell
-----Original Message----- From: Timothy Wall [mailto:twal...@dev.java.net] Sent: quarta-feira, 23 de abril de 2008 16:14 To: use...@jna.dev.java.net Subject: Re: [jna-users] Create a Block hook with jna
Do you have a native example that works? If you're trying something entirely new and you're not sure how to do it, throwing JNA in the mix just adds to the uncertainty if you're not already familiar with it.
On Apr 23, 2008, at 12:26 PM, Maxwell C. Xandeco wrote:
Hi,
I need to create a block keyboard hook on windows, i need to receive the vkCode and validate, if pass i call the next hook, else i ignore the key.
I tried with the example of svn (KeyHook) but I could not, this example call the code java after windows proccess, i need to call before and validate.







