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

java.awt.Robot does not move mouse pointer to the specified position

XMLWordPrintable

    • x86_64
    • windows_10

      FULL PRODUCT VERSION :
      java version "1.8.0_162"
      Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
      Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.16299.214]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Lenovo w540 laptop with two graphics adapters: Intel (the default one) and NVidia. All software updates and latest drivers are installed.

      A DESCRIPTION OF THE PROBLEM :
      The code snippet below demonstrates that java.awt.Robot does not move mouse pointer to the specified position.

      Code:
      public static void main(String[] args) throws Exception {
        Robot robot = new Robot();
        for(int x = 0; x < 1920; x += 192)
        {
          robot.mouseMove(x, 0);
          robot.delay(1_000);
          final Point location = MouseInfo.getPointerInfo().getLocation();
          System.out.println("Expected: " + x + "\t\tReal:" + location.getX());
        }
      }

      Output:
      Expected: 0 Real:0.0
      Expected: 192 Real:239.0
      Expected: 384 Real:421.0
      Expected: 576 Real:614.0
      Expected: 768 Real:807.0
      Expected: 960 Real:998.0
      Expected: 1152 Real:1191.0
      Expected: 1344 Real:1382.0
      Expected: 1536 Real:1574.0
      Expected: 1728 Real:1767.0

      I found similar report https://bugs.openjdk.java.net/browse/JDK-8190898 which is closed as "Incomplete". The problem is perfectly reproducible in my environment and I'm ready to provide all necessary further details about my hardware configuration (Lenovo Thinkpad laptop).

      I found that calling in loop robot.mouseMove(x, 0) finally moves mouse pointer in 3-5 attempts.


      REPRODUCIBILITY :
      This bug can be reproduced always.

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

              Created:
              Updated:
              Resolved: