java.awt.Robot
Levi Yourchuck
Senior Programmer Analyst
G&K Services
Phone: 952 912 5828
www.gkservices.com
Enhancing Image & Safety Through Innovation
This e-mail and any attachments may contain confidential and privileged
information. If you are not the intended recipient, please notify the
sender immediately by return e-mail, delete this e-mail and destroy any
copies. Any dissemination or use of this information by a person other
than the intended recipient is unauthorized and may be illegal.
"Alan Snyder" <ala...@tidebreaksys.com>
08/27/2008 11:44 AM
Please respond to
use...@jna.dev.java.net
To
use...@jna.dev.java.net
cc
Subject
[jna-users] Keyboard hook callback.
Thanks for the response to the previous question. I'm trying to create
hooks
for global mouse and keyboard events on both Mac and PC. Currently working
on the keyboard part for the PC and do have questions about using JNA
here.
I'm trying to install a hook using SetWindowsHookEx(WH_KEYBOARD_LL, ....
but need to understand if the callback can be entirely in JNA or does it
need to be in a separate DLL. If it can be entirely in JNA then what do
you set
HINSTANCE to? Also what should be the returned LRESULT value?
Here is what I have. It doesn't crash in any way, but neither does it
respond to any
keyboard events. (This is using the User32 call in JNA 3.0.5)
final User32 user32 = User32.INSTANCE;
HINSTANCE hInst =
Kernel32.INSTANCE.GetModuleHandle(null);//?What is this really?;
HHOOK hHook = user32.SetWindowsHookEx(User32.WH_KEYBOARD_LL,
new User32.LowLevelKeyboardProc() {
public LRESULT callback(int nCode, WPARAM wParam,
KBDLLHOOKSTRUCT lParam) {
System.out.println("nCode="+nCode);//Just print
something to confirm the callback
//What should we return from here? Zero?
CallNextHookEx?;
return new LRESULT(0);
}
}, hInst, 0);
I did see a similar thread back in Nov. 2007 on this not the conclusion.
Any advise is appreciated.
Alan