Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 678
Chad Avatar asked Mar 01 '26 08:03

Chad


2 Answers

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.

like image 147
Adam Goode Avatar answered Mar 03 '26 22:03

Adam Goode


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

like image 24
Mark Elliot Avatar answered Mar 03 '26 22:03

Mark Elliot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!