public static void Pan(UIObject obj, int distance, Direction direction, uint holdDuration = DefaultPanHoldDuration, float panAcceleration = DefaultPanAcceleration, uint dragDuration = DefaultDragDuration, bool waitForIdle = true) { Log.Comment("Pan on {0} for {1} pixels in the {2} direction, after holding {3} ms.", obj.GetIdentifier(), distance, direction, holdDuration); Log.Comment("Clickable point of pan object is {0}", obj.GetClickablePoint()); Log.Comment("Bounding rectangle of object is {0}", obj.BoundingRectangle); Pan(obj, obj.GetClickablePoint(), distance, direction, holdDuration, panAcceleration, dragDuration, waitForIdle); }
public static void DragToTarget(UIObject obj, UIObject obj2) { Point startPoint = obj.GetClickablePoint(); Log.Comment("Start Point X:{0} Y:{1}", startPoint.X, startPoint.Y); Point end = obj2.GetClickablePoint(); Log.Comment("End Point X:{0} Y:{1}", end.X, end.Y); uint dragDuration = 2000; using (var waiter = GetWaiterForInputEvent(obj, InputEvent.Drag)) { if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5)) { Log.Warning("Touch input is not available on OS versions less than RS5. Falling back to mouse input."); Log.Comment("Move input to Start Point."); PointerInput.Move(startPoint); Log.Comment("Begin Drag."); PointerInput.ClickDrag(end, PointerButtons.Primary, dragDuration); Log.Comment("Drag Complete."); } else { Log.Comment("Move input to Start Point."); SinglePointGesture.Current.Move(startPoint); Log.Comment("Begin Drag."); SinglePointGesture.Current.PressAndDrag(end, dragDuration, 500); Log.Comment("Drag Complete."); } } Wait.ForIdle(); }
public static void MoveMouse(UIObject obj, int offsetX, int offsetY) { Log.Comment("Move mouse on {0} to offset ({1}, {2}).", obj.GetIdentifier(), offsetX, offsetY); using (var waiter = GetWaiterForInputEvent(obj, InputEvent.MouseMove)) { var point = obj.GetClickablePoint(); point.X += offsetX; point.Y += offsetY; PointerInput.Move(point); } Wait.ForIdle(); }
public static void DragDistance(UIObject obj, int distance, Direction direction, uint duration = 4000) { Log.Comment("Drag {0} {1} pixels in the {2} direction.", obj.GetIdentifier(), distance, direction); Point startPoint = obj.GetClickablePoint(); double directionRadians = DirectionToAngle(direction) * Math.PI / 180d; Log.Comment("Start Point X:{0} Y:{1}", startPoint.X, startPoint.Y); Point end = new Point() { X = startPoint.X + (int)Math.Round(distance * Math.Cos(directionRadians)), Y = startPoint.Y - (int)Math.Round(distance * Math.Sin(directionRadians)) }; Log.Comment("End Point X:{0} Y:{1}", end.X, end.Y); using (var waiter = GetWaiterForInputEvent(obj, InputEvent.Drag)) { if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5)) { Log.Warning("Touch input is not available on OS versions less than RS5. Falling back to mouse input."); Log.Comment("Move input to Start Point."); PointerInput.Move(startPoint); Log.Comment("Begin Drag."); PointerInput.ClickDrag(end, PointerButtons.Primary, duration); Log.Comment("Drag Complete."); } else { Log.Comment("Move input to Start Point."); SinglePointGesture.Current.Move(startPoint); Log.Comment("Begin Drag."); SinglePointGesture.Current.ClickDrag(end, PointerButtons.Primary, duration); Log.Comment("Drag Complete."); } } Wait.ForIdle(); }
public static void LeftMouseButtonUp(UIObject obj, int offsetX = 0, int offsetY = 0) { if (offsetX == 0 && offsetY == 0) { Log.Comment("Left mouse button up on {0}.", obj.GetIdentifier()); } else { Log.Comment("Left mouse button up on {0} at offset ({1}, {2}).", obj.GetIdentifier(), offsetX, offsetY); } using (var waiter = GetWaiterForInputEvent(obj, InputEvent.MouseUp)) { var point = obj.GetClickablePoint(); point.X += offsetX; point.Y += offsetY; PointerInput.Move(point); PointerInput.Release(PointerButtons.Primary); } Wait.ForIdle(); }