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

[macos 10.14] Robot.MouseMove no longer works on MacOS 10.14.2 Mojave

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      os_x

      Description

      ADDITIONAL SYSTEM INFORMATION :
      macOS Mojave 10.14.2
      OpenJDK 11.0.2

      A DESCRIPTION OF THE PROBLEM :
      Robot.MouseMove works on MacOS 10.11.6 but does not work on MacOS 10.14.2.

      The mouse does not move when calling Robot.mouseMove

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the provided sample code on macOS Mojave 10.14.2

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The mouse should move in circles
      ACTUAL -
      The mouse does not move

      ---------- BEGIN SOURCE ----------
      package bugreport;

      import java.awt.*;
      import java.io.IOException;

      /**
       * Works for MacOS version 10.11.6 (El Capitan)
       * openjdk version "11.0.1" 2018-10-16
       * OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
       *
       *
       *
       * Fails for MacOS version 10.14.2 (Mojave)
       * openjdk version "11.0.2" 2019-01-15
       * OpenJDK Runtime Environment 18.9 (build 11.0.2+9) *
       *
       * openjdk version "11.0.1" 2018-10-16
       * OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
       *
       * java version "10.0.2" 2018-07-17
       * Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
       *
       * java version "1.8.0_192"
       * Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
       *
       * java version "1.7.0_79"
       * Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
       *
       * The mouse does not move.
       */
      public class RobotMouseMove {

      static final double NANO_TO_RAD = 2 * Math.PI / 1_000_000_000d; // 1 revolution per second

      static public void main(String...args) throws AWTException, InterruptedException, IOException{
      Robot robot = new Robot();

      DisplayMode display = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
      int centerX = display.getWidth() / 2;
      int centerY = display.getHeight() / 2;

      System.out.println("Robot Mouse started");

      long refTime = System.nanoTime();
      int val = 3;
      if(0 < val){
      long duration = val * 1_000_000_000L;
      long elapsedTime;
      do{
      elapsedTime = System.nanoTime() - refTime;

      double angle = elapsedTime * NANO_TO_RAD;
      int x = (int)(Math.cos(angle)*150);
      int y = (int)(Math.sin(angle)*150);
      robot.mouseMove(centerX + x, centerY + y);

      Thread.sleep(8);
      }while(elapsedTime < duration && System.in.available() == 0);
      }

      System.out.println("Robot Mouse stopped");

      System.exit(0);
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None known

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: