/// <summary> /// Fixes the property after a deserialisation /// </summary> /// <param name="property">A reference to the property to be fixed</param> public static void FixType(ref Property property) { switch (property.PropertyType) { case Property.Type.ProjectionSize: if (!(property is ProjectionSize)) property = new ProjectionSize (property); break; case Property.Type.PositionOnScreen: if (!(property is PositionOnScreen)) property = new PositionOnScreen (property); break; case Property.Type.VantageAngle: if (!(property is VantageAngle)) property = new VantageAngle (property); break; case Property.Type.RelativePosition: if (!(property is RelativePosition)) property = new RelativePosition (property); break; } }
public MotionResult ActSequenceMotion(IEnumerable <Motion> SeqMotion) { try { if (null == SeqMotion) { return(null); } var MousePosition = BotEngine.Windows.Extension.User32GetCursorPos() ?? new Vektor2DInt(0, 0); var InputSimulator = new WindowsInput.InputSimulator(); foreach (var Motion in SeqMotion.WhereNotDefault()) { var MotionMousePosition = Motion?.MousePosition; var MotionTextEntry = Motion?.TextEntry; if (MotionMousePosition.HasValue || (Motion.WindowToForeground ?? false)) { EnsureWindowIsForeground(); } if (MotionMousePosition.HasValue) { POINT PositionOnScreen; MouseMoveToPointInClientRect(WindowHandle, MotionMousePosition.Value + MouseOffsetStatic, out PositionOnScreen); MousePosition = PositionOnScreen.AsVektor2DInt(); Thread.Sleep(MouseMoveDelay); } if (0 < Motion?.MouseButtonDown?.Count() || 0 < Motion?.MouseButtonUp?.Count()) { EnsureWindowIsForeground(); User32MouseEvent(MousePosition, Motion?.MouseButtonDown, Motion?.MouseButtonUp); Thread.Sleep(MouseEventDelay); } Motion?.KeyDown?.ForEach(KeyDown => { EnsureWindowIsForeground(); InputSimulator.Keyboard.KeyDown(KeyDown); Thread.Sleep(KeyboardEventTimeDistanceMilli); }); Motion?.KeyUp?.ForEach(KeyUp => { EnsureWindowIsForeground(); InputSimulator.Keyboard.KeyUp(KeyUp); Thread.Sleep(KeyboardEventTimeDistanceMilli); }); if (0 < MotionTextEntry?.Length) { EnsureWindowIsForeground(); InputSimulator.Keyboard.TextEntry(MotionTextEntry); } } return(new MotionResult(true)); } catch (Exception Exception) { return(new MotionResult(Exception)); } }