Howto make Java JNI KeyListener with C++

限于喜欢 提交于 2019-12-24 19:14:37

问题


I'm trying to make a program like AutoHotKey, but with a graphical interface. I'm using java.awt.Robot Now I want to make the code for checking the state from a key (In AHK: getKeyState) Of course somthing like a KeyListener without having focus. I read already something with JNI and C++, but.... I can't find some information.

Can somebody help me??


回答1:


There are lot of good JNI resources for starting out with JNI Programming like the Sun JNI Tutorial. Almost all Tutorials assume a good knowledge of C/C++ because the Java Native Interface (JNI) is the bridge between native C/C++ code, the Java Virtual Machine and everything running in there (meaning your Java Bytecode).

What you may want to do first is to find a key capturing library for your operating system of choice (you didn't mention anything specific here) in C++ and try that out as well as checking if there are already some Java bindings (libraries that use JNI and offer Java classes) to interact with. I didn't find any promising on a quick search unfortunately.




回答2:


works perfect for windows 32/64 Bit. It's not necessary to integrate the dll files into the (eclipse)workspace / deployment process. Amazing Lib:

Hot stuff! http://ksquared.de/blog/2011/07/java-global-system-hook/



来源:https://stackoverflow.com/questions/1335965/howto-make-java-jni-keylistener-with-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!