title: Simulating a mouse pointer click (can move but can't click)
body: <p>I'm trying to simulate a left mouse pointer click (and a double click) at a certain position on the screen.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>[System.Runtime.InteropServices.DllImport("user32.dll")]
  static extern bool SetCursorPos(int x, int y);
  
  [System.Runtime.InteropServices.DllImport("user32.dll")]
  public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
  
  public const int MOUSEEVENTF_LEFTDOWN = 0x02;
  public const int MOUSEEVENTF_LEFTUP = 0x04;
  
  //This simulates a left mouse click
  public static void LeftMouseClick(int xpos, int ypos)
  {
       SetCursorPos(xpos, ypos);
       mouse_event(MOUSEEVENTF_LEFTDOWN, xpos, ypos, 0, 0);
       mouse_event(MOUSEEVENTF_LEFTUP, xpos, ypos, 0, 0);
  }
  </code></pre>
  
  <p>I am able to move the mouse pointer to the coordinates with the above code but I am unable to make the click happen (or a double click). </p>