2 posts in topic
Flat View  Flat View

Posted By:   Phil_Sanwish
Posted On:   Tuesday, September 26, 2006 05:53 PM

Is there anyway to register a hotkey in the system so that when I press ctrl-alt-F2, for example, my program can react, even when it is not focused?

If there is not a pure way to do this, is there any way to get around it. Maybe create a loop which waits until the button is pressed?

Remember, I want it to work even if the program is not focused.

Re: Hotkeys

Posted By:   learner_always  
Posted On:   Monday, December 18, 2006 09:37 AM

You need to use JNI for this.You need to call a native method which is implemented in c/C++.The c++ file is to be coverted to dll which is to be loaded in systems library using System.loadlibrary().

In C++ file you will have to use JNI'api which will get the ref to jre and ref of the class calling the native method.

It would be good if u first know how to use JNI to connect to C/C++ and then nedd to know how to capture key events.The link beneath will help.


If you crack this problem do let me know,even i am facing the same problem.

Re: Hotkeys

Posted By:   Christopher_Koenigsberg  
Posted On:   Wednesday, October 11, 2006 08:37 PM

I think the approach (some kind of keyboard driver filter) would differ depending on whether you want it to work under X11 or under MS Windows, e.g. would be extremely un-Java, extremely platform-dependent? (I think, if I remember correctly, Microsoft's keyboard driver is part of the OS kernel, but X11's keyboard driver, and indeed the whole X11 window "display server", not to mention the particular choice of window "manager", is just running as an ordinary application out in user space, whether on Linux, Solaris, AIX etc.)
About | Sitemap | Contact