I am using the following code from How to simulate Mouse Click in C#? and I have found that it does not work. Here is the code:
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
public void DoMouseClick()
{
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 882, 554, 0, 0);
}
private void button1_Click(object sender, EventArgs e)
{
DoMouseClick();
}
I have also tried replacing mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENT_LEFTUP...
with mouse_event(MOUSEEVENTF_LEFTDOWN & MOUSEEVENT_LEFTUP...
but still no luck. Other people have had success with this... Why am I not?