title: SendInput moves the cursor when I try to perform a mouse click
body: <p>I'm trying to simulate a left mouse button click with SendInput, and it works but also moves the cursor to the upper left corner of the screen (0,0) and I can't figure it out why.</p>
  
  <p>(I'm using the same structures to move the cursor (relatively and absolutely) and that's working.)</p>
  
  <pre><code>private static void Send(INPUT input)
  {
    SendInput(1, ref input, Marshal.SizeOf(new INPUT()));
  }
  private static void MouseAction(MouseFlags mf)
  {
    INPUT aInput = new INPUT();
    aInput.type = InputType.INPUT_MOUSE;
    aInput.mkhi.mi.dwFlags = mf;
  
    Send(aInput);
  }
  
  // Performs a LeftClick but moves the cursor to (0.0)
  public static void LeftClick()
  {
    MouseAction(MouseFlags.MOUSEEVENTF_LEFTDOWN | MouseFlags.MOUSEEVENTF_LEFTUP);
  }
  </code></pre>
  
  <p>The result is the same when I fill out all of the structure members.
  The full INPUT definition:</p>
  
  <pre><code>[StructLayout(LayoutKind.Sequential)]
  struct INPUT
  {
      public InputType type;
      public MouseKeyboardHardwareUnion mkhi;
  }
  [StructLayout(LayoutKind.Explicit)]
  struct MouseKeyboardHardwareUnion
  {
      [FieldOffset(0)]
      public MOUSEINPUT mi;
  
      [FieldOffset(0)]
      public KEYBDINPUT ki;
  }
  [StructLayout(LayoutKind.Sequential)]
  struct MOUSEINPUT
  {
      public int dx;
      public int dy;
      public uint mouseData;
      public MouseFlags dwFlags;
      public uint time;
      public IntPtr dwExtraInfo;
  }
  // Not relevant
  [StructLayout(LayoutKind.Sequential)]
  struct KEYBDINPUT
  {
      public KeyboardVirtual wVk;
      public ushort wScan;
      public KeyboardFlags dwFlags;
      public uint time;
      public IntPtr dwExtraInfo;
  }
  </code></pre>
  
  <p>Filling out the MOUSEINPUT's dx and dy fields with the cursor's current position doesn't seem to solve the problem either.</p>