SendMessage – C#

//DllImport using System.Runtime.InteropServices;
//Left Button - Mouse Down
public const int WM_LBUTTONDOWN = 0x0201;
//Left Button - Mouse Up
public const int WM_LBUTTONUP = 0x0202;
/// <summary>
/// The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread’s message queue and returns immediately.
/// </summary>
///<param name="hWnd"></param>Identifies the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.
///<param name="wMsg"></param>Specifies the message to be sent.
///<param name="wParam"></param>Specifies additional message-specific information.
///<param name="lParam"></param>Specifies additional message-specific information. ///<returns>The return value specifies the result of the message processing and depends on the message sent. </returns>

[DllImport("user32.dll",CharSet=CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
long lngResult = SendMessage(btn1.Handle, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
lngResult = SendMessage(btn1.Handle, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);