I write a code for mouse Click Simulation but there is one problem. It isn't making every second Click but cursor is moving. Can any one help me ? here is a code :
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
[DllImport("user32.dll", EntryPoint = "SetCursorPos")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetCursorPos(int X, int Y);
private const int MOUSEEVENTF_ABSOLUTE = 0x8000;
private const int MOUSEEVENTF_MOVE = 0x0001;
private const int MOUSEEVENT_LEFTDOWN = 0x0002;
private const int MOUSEEVENTF_LEFTUP = 0x0004;
private void button2_Click(object sender, EventArgs e)
{
SetCursorPos(Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text));
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENT_LEFTDOWN | MOUSEEVENTF_LEFTUP, Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text), 0, 0);
Thread.Sleep(1000);
SetCursorPos(Convert.ToInt32(textBox3.Text), Convert.ToInt32(textBox4.Text));
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENT_LEFTDOWN | MOUSEEVENTF_LEFTUP, Convert.ToInt32(textBox3.Text), Convert.ToInt32(textBox4.Text), 0, 0);
Thread.Sleep(1000);
SetCursorPos(Convert.ToInt32(textBox5.Text), Convert.ToInt32(textBox6.Text));
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENT_LEFTDOWN | MOUSEEVENTF_LEFTUP, Convert.ToInt32(textBox5.Text), Convert.ToInt32(textBox6.Text), 0, 0);
Thread.Sleep(1000);
SetCursorPos(Convert.ToInt32(textBox7.Text), Convert.ToInt32(textBox8.Text));
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENT_LEFTDOWN | MOUSEEVENTF_LEFTUP, Convert.ToInt32(textBox7.Text), Convert.ToInt32(textBox8.Text), 0, 0);
Thread.Sleep(1000);
SetCursorPos(Convert.ToInt32(textBox9.Text), Convert.ToInt32(textBox10.Text));
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENT_LEFTDOWN | MOUSEEVENTF_LEFTUP, Convert.ToInt32(textBox9.Text), Convert.ToInt32(textBox10.Text), 0, 0);
Thread.Sleep(1000);
SetCursorPos(Convert.ToInt32(textBox11.Text), Convert.ToInt32(textBox12.Text));
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENT_LEFTDOWN | MOUSEEVENTF_LEFTUP, Convert.ToInt32(textBox11.Text), Convert.ToInt32(textBox12.Text), 0, 0);
Thread.Sleep(1000);
SetCursorPos(Convert.ToInt32(textBox13.Text), Convert.ToInt32(textBox14.Text));
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENT_LEFTDOWN | MOUSEEVENTF_LEFTUP, Convert.ToInt32(textBox13.Text), Convert.ToInt32(textBox14.Text), 0, 0);
Thread.Sleep(1000);
SetCursorPos(Convert.ToInt32(textBox15.Text), Convert.ToInt32(textBox16.Text));
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENT_LEFTDOWN | MOUSEEVENTF_LEFTUP, Convert.ToInt32(textBox15.Text), Convert.ToInt32(textBox16.Text), 0, 0);
Thread.Sleep(1000);
SetCursorPos(Convert.ToInt32(textBox17.Text), Convert.ToInt32(textBox18.Text));
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENT_LEFTDOWN | MOUSEEVENTF_LEFTUP, Convert.ToInt32(textBox17.Text), Convert.ToInt32(textBox18.Text), 0, 0);
}
Thats all.