How do you record keystrokes when operating on another window in Java?

谁都会走 提交于 2019-12-20 03:22:04

问题


I'm looking to record keystrokes and mouse positions while I'm in a browser window on various websites, but I'm not sure how to do this outside the SWING (or some other GUI) window.

How can I record keystrokes when a different application's window is the one active?


回答1:


The support you need is not exposed by Java. It is a fairly simple matter to do this if you have access to the RECORD extension in X, or Win32 on Windows.

Here is a Python project that implements support for both of these platforms: pykeylogger.




回答2:


(Windows only) In theory you could use JNA or JNI to bind to GetAsyncKeyState and you'd be able to monitor key presses.




回答3:


I don't think you can do this from pure Java. If it is possible at all, it would require the assistance of a (highly) platform specific native code library.



来源:https://stackoverflow.com/questions/2010657/how-do-you-record-keystrokes-when-operating-on-another-window-in-java

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