how record all keyboard input in java - java

Hi I want to capture all the keypress events of keyboard happened in perticular session using java program. same like keylogger.
any help would be appriciated.

Maybe you could need a library like the following:
http://kra.lc/blog/2011/07/java-global-system-hook/
It even tracks keypress events if focus lost of an element.

Related

Recognize arrow keys in Java Scanner or Console application

I am writing a Java application that uses both Scanner and Console to get input from the user. I would like to add command history support so that the user can use the ARROW KEYS to search previous inputs (similar to a terminal). Is there a way to do this? Right now, when I use either the Scanner or the Console, I get weird symbols like ^[[A when pressing the arrow keys.
I have read about KeyListener and KeyEvent, but my application does not use a GUI.
Thanks!
Good question - +1'd. On Windows, I would SetConsoleMode to change the console to take raw input, but on *Nix it looks like there is more work involved. Unfortunately I don't have any code that I can show you right now, but have a look at this link and see if it helps.
http://www.darkcoding.net/software/non-blocking-console-io-is-not-possible/

Pressing key at any point to make an action

I'm programming on java, so I have to make a game-like program. The game should be able to "pause" at any point. Can you press a key at any point so a message is displayed saying "game is paused"? Then when you press that key again it will say "game resumed"?
Thanks
It looks like you need to be able to read input directly from the keyboard into your game? Is your game built into a GUI or in the console?
This can be done by using the KeyListener interface Java provides.
https://docs.oracle.com/javase/7/docs/api/java/awt/event/KeyListener.html
I'll assume your using swing so this tutorial should be pretty useful.
http://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html
Sorry I can't go into more detail, more information about what you are trying to do in the comments would help me help you.
Edit: You mentioned you're using the command line. To get user input you can use java.util.Scanner
http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html
Make a boolean, isPaused. If space is pressed, switch isPaused from true to false or vice versa. If isPaused is true, run the game, if not, run a pause screen instead.

How to generate mouse events with pressure?

I want to emulate wacom tablet in such way, that different apps like photoshop will resive my mouse events with pressure. How can I do it?
Java API is oriented to normal mouse events. Using a mouse device does not give you a sense of pressure, as the device does not provide such input. If a normal mouse is your input device, then you have no way to get such info.
You could however imitate such input functionality, using the time interval of the mouse button being clicked. I would suggest using the "key down" and the "key up" event of the mouse click and translate the time difference between them as an indicator of the "pressure". Perhaps this tutorial could give you some guidance.
Another idea would be to get somehow info from the device directly. You could use the device API to get direct input and wrap it in your application.
Hope I helped!

Converting Serial input to Keyboard Button-press

Not sure if I'm asking this question on the correct site (I have been wondering if this should rather be posted on the EE.stackoverflow site).
So I have an OLD serial input mouse, and I want the system to reprogram or retranslate it to a keyboard button-press.
The whole thing is that I have software with shortcut keys, but remembering all of them is just not possible. So, why does one want to have a whole keyboard when one can only have a set of three buttons? Using a keyboard, when one presses F11 (and holds it in), it activates the system's mic. While holding in F11, one wants to press F1 to start playing music, thus being a voice over song application.
I've been trying to research the possibility, and I've come to notice that there are a LOT of applications that can convert a USB device, such as a game controller to a keyboard button-press. That's what's driving my concept.
Is this even possible?
Thanks,
Johan Brink
Well, as described here, if you are using Windows, you can use X-Mouse Button Control for mouse. If you want to use gamepad, try J2K - A Joystick to Keyboard Mapper 1.1
Have a look on Makey Makey (www.makeymakey.com). This is a board which emulates a key stroke each time one of his input is closed.

barcode scanner polling

I am working with a bar code scanner and java currently. i wanted to know wether there is a possibility to poll this device.
What I want: a popup message every time you scan a barcode
What I dont want: is to focus a text field first to do so.
I want this to run in the background so that the user only has to scan something without anything in focus. is this possible?
in other words, i dont want to use it like a keyboard but more like a sensor that informs me every time a new value is available.
thank in advance
i think these mostly work as keyboard input.
you could probably create a KeyListener() to check for the incoming values.
Yes you can listen barcode scanning detection on your whole hardware at anytime example:PC or Laptop or Tablet etc.
For that you need to add barcode scanner listener on your main file which is available to all the pages or all the urls of your application.
You can use my custome script from my answer on stackoverflow

Categories