0 Replies Latest reply: Apr 2, 2012 3:00 AM by 927811 RSS

    java.awt.Robot atomic operation (KeyPress + KeyRelease)

      I want just to know, if I code as follow:-


      Does it guaranteed that the program will simulate key "A", only once?
      I mean, when I do not write

      <code> robot.keyRelease(KeyEvent.VK_A) </code>

      Then the usual output shows :- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa......... until I press any key, even after program exits.

      But when I usually use both statements, this normally not happen. But something strange happens while working last night. I use the following:-

      robot.keyPress(KeyEvent.CTRL_MASK) // one more question?- should I use CTRL_DOWN_MASK here, instead

      I want to simulate "*ctrl+a*". But instead of expected result (*select all*), I got the following output:-
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa........ (about 16-17 "a", and then it automatically stopped).

      Same is the case with "*shift+a*".
      The problem happened, when I was running this code in "netbeans environment".

      The problem what I'm suspecting is probably due to OS multiprocessing/multithreading environment. Please suggest me to make these two statements atomic, something else to deal with this problem........