Currently running a program through ssh in terminal. To control the program I need to type certain keys ('i', 'j', 'l', or ','). I'm trying to use a java class in order to simulate these key presses based on certain inputs, but I've run into a couple issues.
1) Without the terminal in focus, the simulated key presses do not do anything. I have a vb script to change focus to other windows, but was told I'd need a couple of extra steps to start the script from the java class. I was also thinking that maybe there was something in Runtime.whatever to do just a key press, but I am unfamiliar with it.
2) Even if I can do one of the above, I'm not sure that the "simulated" key press would be enough to control the program. As it is, I tried running my Java project and switching manually to terminal before the key press was simulated, but it had no effect.
Any input/help with these ideas, or suggestions to otherwise accomplish my task would be greatly appreciated. If need be I can try to supply more detail.
Thanks!
UPDATE: So when I manually switch to terminal the simulated key presses actually work. I guess the first time I wasn't quick enough. So I just need to switch focus to terminal automatically and problem solved.