title: programmatically mouse click in another window
body: <p>Is it possible to click programmatically a location in another window without moving the mouse to that location and even if the window is not on-top? I want to send a kind of message to another window to simulate a mouse click on a location. </p>
  
  <p>I tried to accomplish this with PostMessage:</p>
  
  <pre><code>PostMessage(WindowHandle, 0x201, IntPtr.Zero, CreateLParam(300,300));
  PostMessage(WindowHandle, 0x202, IntPtr.Zero, CreateLParam(300,300));
  </code></pre>
  
  <p>I made the CreateLParam function this way:</p>
  
  <pre><code>private static IntPtr CreateLParam(int LoWord, int HiWord)
  {
       return (IntPtr)((HiWord &lt;&lt; 16) | (LoWord &amp; 0xffff));
  }
  </code></pre>
  
  <p>The problem is that the window gets locked on his location. I think that my application clicks on the (1,1) coordinate. Can some on help me with this problem?</p>
  
  <p>Edit:
  This is PostMessage:</p>
  
  <pre><code>[return: MarshalAs(UnmanagedType.Bool)]
  [DllImport("user32.dll")]
  public static extern bool PostMessage(IntPtr WindowHandle, int Msg, IntPtr wParam, IntPtr lParam);
  </code></pre>
  
  <p>And 0x201 and 0x202 are WM_LBUTTONDOWN and WM_LBUTTONUP respectively.</p>