0

I'm having a funny ol' time with PostMessage, wondering if anybody could enlighten me.

The method below processes the first left click but not the second, I did a bit of messing around and found that using a MessageBox and hitting OK even instantly provides the delay/release or whatever it is that's needed to make the second left click process.

public void MouseClick(IntPtr handle)
{
    PostMessage(handle, (uint)WMessages.WM_LBUTTONDOWN, 0, MAKELPARAM(521, 147));
    PostMessage(handle, (uint)WMessages.WM_LBUTTONUP, 0, MAKELPARAM(521, 147));
    //MessageBox.Show("WAITING...");
    PostMessage(handle, (uint)WMessages.WM_LBUTTONDOWN, 0, MAKELPARAM(675, 527));
    PostMessage(handle, (uint)WMessages.WM_LBUTTONUP, 0, MAKELPARAM(675, 527));
}

Thanks in advance.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Spark
  • 1,007
  • 1
  • 8
  • 26

1 Answers1

-2

That is because the main thread message pump is suspended while you are in the MouseClick function. The messagebox call re-enables the message pump. What you can do is call Application.DoEvents or do it in another thread.

Mark PM
  • 2,909
  • 14
  • 19