این کد توی تاپیک "1001 نکته در سی شارپ" قرار داره!!
private const UInt32 WM_LBUTTONDOWN = 0x201;
private const UInt32 WM_LBUTTONUP = 0x202;
[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr handle, UInt32 message,int wParam,int lParam);
public static void SendClick(Control receiver)
{
if (receiver != null)
{
SendMessage(receiver.Handle, WM_LBUTTONDOWN, 0, 0);
SendMessage(receiver.Handle, WM_LBUTTONUP, 0, 0);
}
}
مثال :
private void button1_Click(object sender, EventArgs e)
{
SendClick(button2);
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("2");
}