LolSalad Grandmaster Cheater
Reputation: 1
Joined: 26 Aug 2007 Posts: 988 Location: Australia
|
Posted: Mon Jul 07, 2008 7:38 pm Post subject: PostMessage with mouse click. |
|
|
What I want to do is simple; send a series of mouse clicks to a window using PostMessage. I've tried a heap of things, but nothing I can find seems to work.
The Delphi source code that I've used to test: | Code: | procedure TForm1.Timer1Timer(Sender: TObject);
var
w:TPoint;
fWnd:HWND;
l:Longbool;
l2:Longbool;
r:TRect;
begin
GetCursorPos(w);
fWnd := FindWindow(nil, 'Calculator');
GetWindowRect(fWnd, r);
l := PostMessage(fWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(w.X - r.Left, w.Y - r.Top));
l2 := PostMessage(fWnd, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(w.X - r.Left, w.Y - r.Top));
Label1.Caption := IntToStr(fWnd) + ', ' + IntToStr(r.Left) + ', ' + IntToStr(r.Top) + ', ' + BoolToStr(l) + ', ' + BoolToStr(l2);
end; |
It should be sending a mouse click into the calculator window every second, but it's not. GetWindowRect is working, and it's getting the calculator window handle fine, but no mouse clicks are getting sent because the two PostMessages are returning -1, rather than 0.
Can someone point out where I am going wrong?
_________________
|
|