N
norbity
Guest
Hi! I tried to make a bot program by simulate mouse click to other program using SendMessage function.
SendMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
Sleep(200);
SendMessage(hwnd, WM_LBUTTONUP, 0, 0);
it works fine, but the problem is that all mouse move events are picked up by the process even if the mouse is outside of its clien area, so lbuttonup happens in wrong pos.
somehow figured out lbuttondown activates mouse capture to pick up all messages until lbuttonup is posted.
so maybe it should be like this.
SendMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
ReleaseCapture();
Sleep(200);
SendMessage(hwnd, WM_LBUTTONUP, 0, 0);
but cant find way to triger ReleaseCapture() in the target program.
also tried SendMessage(hwnd, CaptureChanged, ...) to triger ReleaseCapture(), but didnt work.
even without Sleep(200); command, the slight delay between down and up messages causes same problem.
plus, I found similar issue at C# forum, but couldn't understand the code.(social.msdn.microsoft.com/Forums/vstudio/en-US/8e85eb78-77f2-485f-9bd3-3eaa44233a8a/mousedown-and-mousemove-events?forum=csharpgeneral)
any methods to simulate the mouse click event correctly independent to current mouse move would be fine.
any good idea?
Continue reading...
SendMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
Sleep(200);
SendMessage(hwnd, WM_LBUTTONUP, 0, 0);
it works fine, but the problem is that all mouse move events are picked up by the process even if the mouse is outside of its clien area, so lbuttonup happens in wrong pos.
somehow figured out lbuttondown activates mouse capture to pick up all messages until lbuttonup is posted.
so maybe it should be like this.
SendMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
ReleaseCapture();
Sleep(200);
SendMessage(hwnd, WM_LBUTTONUP, 0, 0);
but cant find way to triger ReleaseCapture() in the target program.
also tried SendMessage(hwnd, CaptureChanged, ...) to triger ReleaseCapture(), but didnt work.
even without Sleep(200); command, the slight delay between down and up messages causes same problem.
plus, I found similar issue at C# forum, but couldn't understand the code.(social.msdn.microsoft.com/Forums/vstudio/en-US/8e85eb78-77f2-485f-9bd3-3eaa44233a8a/mousedown-and-mousemove-events?forum=csharpgeneral)
any methods to simulate the mouse click event correctly independent to current mouse move would be fine.
any good idea?
Continue reading...