private static void SendMouseInput(int x, int y, NativeEnums.MouseEventFlags flag) { NativeStructs.INPUT mouseInput = new NativeStructs.INPUT(); mouseInput.type = NativeEnums.SendInputEventType.InputMouse; mouseInput.mkhi.mi.dx = NativeUtilities.CalculateAbsoluteCoordinateX(x); mouseInput.mkhi.mi.dy = NativeUtilities.CalculateAbsoluteCoordinateY(y); mouseInput.mkhi.mi.mouseData = 0; mouseInput.mkhi.mi.dwFlags = flag | NativeEnums.MouseEventFlags.Absolute; NativeMethods.SendInput(1, ref mouseInput, Marshal.SizeOf(new NativeStructs.INPUT())); }
protected override void ButtonUp(System.Windows.Forms.MouseButtons button, int x, int y) { NativeEnums.MouseEventFlags flag; switch (button) { case System.Windows.Forms.MouseButtons.Left: flag = NativeEnums.MouseEventFlags.LeftUp; break; case System.Windows.Forms.MouseButtons.Right: flag = NativeEnums.MouseEventFlags.RightUp; break; case System.Windows.Forms.MouseButtons.Middle: flag = NativeEnums.MouseEventFlags.MiddleUp; break; default: throw new NotImplementedException(button.ToString()); } NativeMethods.mouse_event((uint)(flag | NativeEnums.MouseEventFlags.Absolute), (uint)NativeUtilities.CalculateAbsoluteCoordinateX(x), (uint)NativeUtilities.CalculateAbsoluteCoordinateY(y), 0, IntPtr.Zero); }
public override void MoveTo(int x, int y) { NativeMethods.mouse_event((uint)(NativeEnums.MouseEventFlags.Move | NativeEnums.MouseEventFlags.Absolute), (uint)NativeUtilities.CalculateAbsoluteCoordinateX(x), (uint)NativeUtilities.CalculateAbsoluteCoordinateY(y), 0, IntPtr.Zero); }