开发者

capture key strokes in windows

is it even possible to build (in JAVA) application that gets keyboard strokes done on any application in windows (not in java application it self) ?!!开发者_如何学编程


Yes I believe it is possible, but you'd have to use JNI to do it as it requires use of the Windows API as described here.


Yes, throught JNI using the Windows API. But it will not be portable.


Java by itself does not have any facility to perform this kind of thing.

You have to use JNI to create a native DLL using the Windows API that will be called by your Java code through the System.loadLibrary(String libname) method.


First, this is right that you can capture events on the java application window only. Second, it is wrong that your problem may be solved using JNI API only. I tried the following trick.

Create transparent full screen window. Capture events on it. When you captured the keystroke quickly disappear the window and simulate the same key press using Robot. Then create the transparent full screen window again.

This is ugly trick but it is pure java and user does not see anything. Good luck.


Wow.. look at the way people are answering..
3 mins ago some one suggested JNI.

Yes, throught JNI using the Windows API. But it will not be portable.

1 min ago some one else thought of answering too..

Yes I believe it is possible, but you'd have to use JNI to do it as it requires use of the Windows API as described here.

24 seconds ago someone else thought about it too...

Java by itself does not have any facility to perform this kind of thing. You have to use JNI to create a native DLL using the Windows API that will be called by your Java code through the System.loadLibrary(String libname) method.

I too think the same thing..
Use JNI dude.. :D

We need something in SF to prevent this !! If someone already suggested JNI, others shouldn't be able to post the same.. Let them add to the comment or upvote the already existing comment..!!

edit - and yeah, I am waiting for downvotes and critics here.. Let it begin!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜