title: Send right click to a window
body: <p>I'm trying to send a right mouse click to a window specified coordinates.</p>
  
  <p>I've tested with 2 codes</p>
  
  <p>Code 1:</p>
  
  <pre><code>[DllImport("user32.dll")]
  public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
  [DllImport("user32.dll")]        
  static extern bool ScreenToClient(IntPtr hWnd, ref POINT lpPoint);
  
  public struct POINT
  {
      public int x;
      public int y;
  }
  
  var client = Process.GetProcessesByName("client_dx");
  var whandle = client.MainWindowHandle;
  
  POINT point = new POINT();
  point.x = 1836;
  point.y = 325;
  ScreenToClient(whandle, ref point);
  int lparm = (point.x &lt;&lt; 16) + point.y;    
  int lngResult = SendMessage(whandle, 0x0204, 0, lparm);
  int lngResult2 = SendMessage(whandle, 0x0205, 0, lparm);
  </code></pre>
  
  <p>Code 2:</p>
  
  <pre><code>[DllImport("user32.dll")]
  public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
  [DllImport("user32.dll")]        
  static extern bool ScreenToClient(IntPtr hWnd, ref POINT lpPoint);
  
  public struct POINT
  {
      public int x;
      public int y;
  }
  
  public int MakeLParam(int LoWord, int HiWord)
  {
      return (int)((HiWord &lt;&lt; 16) | (LoWord &amp; 0xFFFF));
  }
  
  var client = Process.GetProcessesByName("client_dx");
  var whandle = client.MainWindowHandle;
  
  POINT point = new POINT();
  point.x = 1836;
  point.y = 325;
  
  ScreenToClient(whandle, ref point);
  
  int lparm = MakeLParam(point.x, point.y);
  int lngResult = SendMessage(whandle, 0x0204, 0, lparm);
  int lngResult2 = SendMessage(whandle, 0x0205, 0, lparm);
  </code></pre>
  
  <p>It's sending a right click but not to the correct coordinates, seems like it ignores the coordinates I specify in LPARAM, because if I move the mouse around the window, it's clicking everywhere I put the mouse pointer but not in the coordinates that I specify.</p>
  
  <p>I've tested changing this line in code 2:</p>
  
  <pre><code>int lparm = MakeLParam(point.x, point.y);
  </code></pre>
  
  <p>To this one:</p>
  
  <pre><code>int lparm = (point.x &lt;&lt; 16) + point.y;
  </code></pre>
  
  <p>But doesn't work, I'm getting the same results...</p>