Results 1 to 5 of 5
  1. #1
    vinc is offline Member
    Join Date
    Nov 2009
    Posts
    3
    Rep Power
    0

    Exclamation How to send keystroke/text to some another application/process

    Hi,
    does anybody know how to send keystroke or text to another application? The "another" application is not java application but it is for example notepad.
    For example if I create two processes:

    Process proc1 = Runtime.getRuntime().exec("notepad");
    Process proc2 = Runtime.getRuntime().exec("notepad");

    And I would like to send some text to some of this processes.
    I have tried to use class Robot:

    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_A);

    The problem is, that this class sends the keystroke only to that window which is on top. I need to choose the particular process which the keystroke or some text receive.

    Thanks in advance;)

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  3. #3
    vinc is offline Member
    Join Date
    Nov 2009
    Posts
    3
    Rep Power
    0

    Default

    Thank you for advice, I'll try this tool. However I have another question. Is it in java even possible to send keystroke to some specific application? Because I found similar topic on another forum, where somebody stated, that only way how to do this in java is via using some library in C++.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  5. #5
    vinc is offline Member
    Join Date
    Nov 2009
    Posts
    3
    Rep Power
    0

Similar Threads

  1. Sava data to a text file from an application?
    By happytrails in forum New To Java
    Replies: 5
    Last Post: 04-10-2009, 07:30 PM
  2. How to make virtual keystroke output?
    By Lynx09 in forum Suggestions & Feedback
    Replies: 2
    Last Post: 03-31-2009, 12:33 AM
  3. More than one KeyStroke (Shortcut) for a JMenuItem
    By hannehomuth in forum Advanced Java
    Replies: 0
    Last Post: 07-25-2008, 03:35 PM
  4. how to read single Keystroke without using return
    By oomanamemni in forum New To Java
    Replies: 1
    Last Post: 02-14-2008, 07:21 PM
  5. Replies: 1
    Last Post: 07-29-2007, 10:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •