Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8246724

Robot.mouseMove() not working when Task Manager or Terminal is focused

XMLWordPrintable

    • x86_64
    • windows_10

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10, 64 bit, Version 1909
      JDK 14.0.1, 64 bit


      A DESCRIPTION OF THE PROBLEM :
      This problem could be related to the "resolved" JDK-8196605.
      I am using Robot.mouseMove() to move the cursor to a specific location on the screen.
      This works when e.g. focusing my IDE's (IntelliJ IDEA) window. When I focus another window and Robot.mouseMove() gets called, the mouse doesn't move at all.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      My attached source code is a minimal example showcasing this behavior.
      Just start the script, focus the Task Manager or Terminal and wait until "Moving" gets printed.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The cursor should get moved to position (0, 0).
      ACTUAL -
      The cursor doesn't get moved at all.

      ---------- BEGIN SOURCE ----------
      import java.awt.Robot;

      public class Test {

          public static void main(String[] args) throws Throwable {
              final Robot robot = new Robot();
              Thread.sleep(5000);
              System.out.println("Moving");
              robot.mouseMove(0, 0);
          }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Focus another window, which might work (I tested with Microsoft Edge, WhatsApp Desktop and IntelliJ IDEA, which seem to work. I haven't yet found out, which programs work with that).

      FREQUENCY : always


        1. Test.java
          0.3 kB
          Pardeep Sharma

            serb Sergey Bylokhov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: