Difference between SendMessage and SendInput for faking a mouse click
I used to use the following code to fake mouse click on a check box:
SetCursorPos(rect.left + 0xA, rect.top + 0x5);
SendMessage(bHandle, WM_LBUTTONDOWN, 0, 0x000A0005);
SendMessage(bHandle, WM_LBUTTONUP, 0, 0x000A0005);
The problem is that the result is random --- sometimes the code successfully check/uncheck the box, sometime it fails (I can see the cursor is moved on top of the box, but the click doesn't happen).
I searched the board, and see someone mentioned using SendInput function to generate mouse click. I will try it but, does anyone know what's the difference between the two approaches?
Thank you in advance!