java - AWT Robot not able to drag a window -
i'm trying move windows explorer window using awt robot. robot running in java 7, , os windows 7.
i'm able move mouse , click on things, when try click-and-drag, doesn't seem pressing button @ all. can't see what's wrong, or think of how figure out what's happening.
i started out using sikuli:
mouse.mousedown(inputevent.button1_mask); mouse.drop(targetlocation);
when didn't work, tried lower-level implementation, working robot directly:
robot robot = new robot(); robot.mousepress(inputevent.button1_mask); robot.mousemove(targetlocation.getx(), targetlocation.gety()); robot.mouserelease(inputevent.button1_mask);
the mouse starts in correct place , moves correct destination, doesn't seem press button.
in sikuli use mouse.drag() mouse.drop(). example:
screenregion fullscreenregion=new screenregion(); imagetarget dragimagetarget=new imagetarget("dragtargetfile"); screenregion dragtargetregion=fullscreenregion.find(dragimagetarget); imagetarget dropimagetarget=new imagetarget("droptargetfile"); screenregion droptargetregion=fullscreenregion.find(dropimagetarget); mouse mouse = new desktopmouse(); mouse.drag(dragtargetregion.getcenter()); mouse.drop(droptargetregion.getcenter());
for java robot api: should call mousemove(), mousepress(), mousemove(), , mouserelease() in order. example:
robot robot=new robot(); // drag robot.mousemove(x1, y1); robot.mousepress(inputevent.button1_mask); // drop robot.mousemove(x2, y2); robot.mouserelease(inputevent.button1_mask);
Comments
Post a Comment