internal static ResponseStatus SendMouseAction( string actionType, int buttonNumber) { var responseStatus = ResponseStatus.UnknownError; PointerButtons button; switch (buttonNumber) { case 0: button = PointerButtons.Primary; break; case 1: button = PointerButtons.Middle; break; case 2: button = PointerButtons.Secondary; break; default: throw new ArgumentException(message: string.Format(format: "Bad mouse button value: {0}. Valid values are LEFT = 0, MIDDLE = 1, RIGHT = 2", arg0: buttonNumber)); } if (!(actionType == "buttondown")) { if (!(actionType == "buttonup")) { if (actionType == "click") { using (InputController.Activate(inputType: PointerInputType.Mouse)) { PointerInput.Click(button: button, count: 1); } responseStatus = ResponseStatus.Success; } } else { using (InputController.Activate(inputType: PointerInputType.Mouse)) { PointerInput.Release(button: button); } responseStatus = ResponseStatus.Success; } } else { using (InputController.Activate(inputType: PointerInputType.Mouse)) { PointerInput.Press(button: button); } responseStatus = ResponseStatus.Success; } return(responseStatus); }
public static void TapAndHold(UIObject obj, uint durationMs) { Log.Comment("Tap and hold on {0} for {1} ms.", obj.GetIdentifier(), durationMs); using (var waiter = GetWaiterForInputEvent(obj, InputEvent.Tap)) { if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5)) { Log.Warning("Touch input is not available on OS versions less than RS5. Falling back to mouse input."); PointerInput.Move(obj); PointerInput.Press(PointerButtons.Primary); Wait.ForMilliseconds(durationMs); PointerInput.Release(PointerButtons.Primary); } else { obj.TapAndHold(durationMs); } } Wait.ForIdle(); }
internal static ResponseStatus SendTouchTypePress(string touchType, int x, int y) { var responseStatus = ResponseStatus.UnknownError; var point = new PointI(x: x, y: y); if (!(touchType == "down")) { if (!(touchType == "move")) { if (touchType == "up") { using (InputController.Activate(inputType: PointerInputType.MultiTouch)) { PointerInput.Move(point: point); PointerInput.Release(button: PointerButtons.Primary); } responseStatus = ResponseStatus.Success; } } else { using (InputController.Activate(inputType: PointerInputType.MultiTouch)) { PointerInput.Move(point: point); } responseStatus = ResponseStatus.Success; } } else { using (InputController.Activate(inputType: PointerInputType.MultiTouch)) { PointerInput.Move(point: point); PointerInput.Press(button: PointerButtons.Primary); } responseStatus = ResponseStatus.Success; } return(responseStatus); }
public static void LeftMouseButtonDown(UIObject obj, int offsetX = 0, int offsetY = 0) { if (offsetX == 0 && offsetY == 0) { Log.Comment("Left mouse button down on {0}.", obj.GetIdentifier()); } else { Log.Comment("Left mouse button down on {0} at offset ({1}, {2}).", obj.GetIdentifier(), offsetX, offsetY); } using (var waiter = GetWaiterForInputEvent(obj, InputEvent.MouseDown)) { var point = obj.GetClickablePoint(); point.X += offsetX; point.Y += offsetY; PointerInput.Move(point); PointerInput.Press(PointerButtons.Primary); } Wait.ForIdle(); }