namespace WindowsFormsApplication1{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private const uint MOUSEEVENTF_LEFTDOWN = 0x0002;
private const uint MOUSEEVENTF_LEFTUP = 0x0004;
[DllImport("user32.dll")]
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, uint dwExtraInf);
private void textBox1_MouseDown(object sender, MouseEventArgs e)
{
try
{
uint x = (uint)Cursor.Position.X;
uint y = (uint)Cursor.Position.Y;
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);//make left button down
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);//make left button up
}
catch (Exception exception)
{
Console.WriteLine(exception);
throw;
}
}
private void Form2_Load(object sender, EventArgs e)
{
textBox1.Text = "b";
}
private void textBox1_MouseLeave(object sender, EventArgs e)
{
Application.Exit();
}
}
}