3737import java .awt .Desktop ;
3838import java .awt .GraphicsConfiguration ;
3939import java .awt .GraphicsDevice ;
40+ import java .awt .Rectangle ;
4041import java .awt .event .ActionEvent ;
4142import java .awt .event .ActionListener ;
4243import java .awt .event .KeyEvent ;
@@ -430,13 +431,14 @@ public void processReceivedObject(Serializable object) {
430431 } else if (object instanceof MouseMoveRequest ) {
431432
432433 final MouseMoveRequest request = (MouseMoveRequest ) object ;
433- final int x ;
434- final int y ;
434+ final GraphicsConfiguration screenConfiguration = screen .getDefaultConfiguration ();
435+
436+ int x ;
437+ int y ;
435438
436439 // On Windows systems we need to convert the coordinates
437440 // according to the current screen scaling factor.
438441 if (SystemUtils .IS_OS_WINDOWS ) {
439- final GraphicsConfiguration screenConfiguration = screen .getDefaultConfiguration ();
440442 final AffineTransform transform = screenConfiguration .getDefaultTransform ();
441443 final double scaleX = (transform != null && transform .getScaleX () > 0 ) ?
442444 transform .getScaleX () : 1 ;
@@ -450,6 +452,16 @@ public void processReceivedObject(Serializable object) {
450452 y = request .y ;
451453 }
452454
455+ // Calculate absolute coordinates for the selected screen.
456+ // Required for multi monitor setups.
457+ Rectangle bounds = screenConfiguration .getBounds ();
458+ //LOGGER.debug("screen bounds {} x {}", bounds.x, bounds.y);
459+ //LOGGER.debug("screen size {} x {}", bounds.width, bounds.height);
460+ //LOGGER.debug("mouse coords {} x {}", x, y);
461+ x += bounds .x ;
462+ y += bounds .y ;
463+ //LOGGER.debug("move mouse to {} x {}", x, y);
464+
453465 robot .mouseMove (x , y );
454466
455467 } else if (object instanceof MousePressRequest ) {
0 commit comments