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

Mouse speed is reset to default

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • tbd
    • 7u55, 8
    • client-libs
    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.7.0_55"
      Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601] (Windows 7 x64).
      However, I assume *ANY* windows version will be ok.

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Not relevant

      A DESCRIPTION OF THE PROBLEM :
      When java.awt.Robot class is used to move system mouse cursor, occasionally it resets the mouse move speed to default.

      This happens because windows implementation of Robot, \jdk\src\windows\native\sun\windows\awt_Robot.cpp doesn't check if a call to SystemParametersInfo(SPI_GETMOUSESPEED, 0, &oldSpeed,0) succeeds. As oldSpeed variable is initialized by 10 (default value), the next call ( bResult = SystemParametersInfo(SPI_SETMOUSESPEED, 0, (PVOID)oldSpeed,
                                           SPIF_SENDCHANGE);
      ) will rewrite the actual value to 10.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) You need to configure mouse speed which is not default, i.e. slower or faster
      2) Move a mouse to any coordinates by calling java.awt.Robot#mouseMove

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Mouse speed is not affected by this call
      ACTUAL -
      Mouse speed is reset to default

      REPRODUCIBILITY :
      This bug can be reproduced often.

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

      /**
       * Created by dgalimov on 16.04.14.
       */
      public class Main {

          public static void main(String[] args) throws AWTException, InterruptedException {
              while (true) {
                  Point currentLocation = MouseInfo.getPointerInfo().getLocation();
                  new Robot().mouseMove(currentLocation.x, currentLocation.y);
                  Thread.sleep(1);
              }
          }
      }

      ---------- END SOURCE ----------

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

              Created:
              Updated:
              Resolved: