在 Java 中调用 Windows hook 函数来实现全局键盘监听,需要使用到 JNI (Java Native Interface)。
首先,你需要使用 JNI 的 FindClass
和 GetMethodID
函数获取到 Java 中的 System
类和其中的 out
属性。
然后,你可以使用 JNI 的 GetObjectField
函数获取到 out
属性对应的 PrintStream
对象。
接着,你可以使用 JNI 的 GetMethodID
函数获取到 PrintStream
类中的 println
方法的方法 ID。
最后