public void mouseWheel(int wheelAmt) { robot.mouseWheel(wheelAmt); }
@Override public void rotateMouseWheel(int amount) { robot.mouseWheel(amount); }
@Override public void scroll( int amount ) { robot.mouseWheel( amount ); FXTestUtils.awaitEvents(); } }
@Override public void mouseWheel(int wheelAmt) { this.robot.mouseWheel(wheelAmt); this.delayForPressRelease(); }
@Override public void mouseWheel(MasterMouseEvent mouseEvent){ robot.mouseWheel(mouseEvent.getMouseWheel()); }
import java.awt.Robot; public class Test{ public static void main(String[] args) throws Exception { //time to switch to a specific window where the robot ought to be tested try{ Thread.sleep(2000); }catch(InterruptedException e){} Robot r = new Robot(); for(int i = 0; i < 20; i++){ //scroll and wait a bit to give the impression of smooth scrolling r.mouseWheel(1); try{ Thread.sleep(50); }catch(InterruptedException e){} } } }
import java.awt.AWTException; import java.awt.Robot; public class TestRobotScroll { public static void main(String[] args) { try { Robot bot = new Robot(); bot.setAutoDelay(100); Thread.sleep(2000); System.out.println("++"); bot.mouseWheel(25); Thread.sleep(2000); System.out.println("--"); bot.mouseWheel(-25); } catch (Exception ex) { ex.printStackTrace(); } } }
public static void mouseWheel(ActionContext actionContext){ Thing self = (Thing) actionContext.get("self"); java.awt.Robot robot = (java.awt.Robot) self.doAction("getRobot", actionContext); Integer wheelAmt = (Integer) self.doAction("getWheelAmt", actionContext); robot.mouseWheel(wheelAmt); }
robot.mouseWheel(-40); robot.mouseWheel(40);
public void replay(IMouseEventLog mouse) { Insets insets = frame.getInsets(); MouseEventType type = mouse.getType(); if(type==MouseEventType.MOUSE_CLICKED) getRobot().mousePress(mouse.getButton()); else if(type==MouseEventType.MOUSE_PRESSED){ getRobot().mousePress(mouse.getButton()); } else if(type==MouseEventType.MOUSE_RELEASED){ getRobot().mouseRelease(mouse.getButton()); } else if(type==MouseEventType.MOUSE_DRAGGED){ getRobot().mouseMove(moveX(mouse, insets), moveY(mouse, insets)); } else if(type==MouseEventType.MOUSE_MOVED){ getRobot().mouseMove(moveX(mouse, insets), moveY(mouse, insets)); } else if(type==MouseEventType.MOUSE_WHEEL){ getRobot().mouseWheel(mouse.getValue()); } //if(type!=MouseEventType.MOUSE_DRAGGED && type!=MouseEventType.MOUSE_MOVED) // log(mouse); }