0

I want to run a child process in my java program to create automation. I do not have the source code of the child process.

There are some functionality requires pressing the arrow keys in the child process.

I can send ASCII characters into the child process through the child process's STDIN, but how can I send arrow keys to the child process?

Michael
  • 53
  • 2
  • Is this a question on threads, or are you asking how to implement code to detect an arrow key press? – cworner1 Dec 24 '12 at 00:53
  • I doubt you can encode an arrow key into an ASCII character: arrow key is detected and managed by the command line editor, it's NOT a character that can be sent to as standard input. – Luigi R. Viggiano Dec 24 '12 at 01:00

1 Answers1

0

Look at java.awt.Robot (keyPress/keyRelease). This allows you to send keyboard events, mouse movements and mouse clicks to your OS (among other things).

I suspect sending keyboard events to a specific process (rather than just the OS) is beyond what Java can natively do, though C/C++/C# can probably do something like that.

Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138