Home > Back-end >  For help on Delphi sendmessage problem
For help on Delphi sendmessage problem

Time:11-07

I have a program, in the form has three handles, I want to simulate mouse single in the background, the game does not block sendmessage postmessage API, but has been unable to achieve, please the great god guide, the code is as follows:
Procedure TForm1. Button1Click (Sender: TObject);
Var
Fu zi, sun: Thandle;//the father, son, Sun San handle
Ps: TPoint;
The begin

Fu:=FindWindow (' Client - I4194304 ', 'battlefield 2 official server');
If fu<> 0 then
The begin
Zi:=FindWindowEx (fu, 0, nil nil);
//
If zi<> 0 then
The begin
Sun:=FindWindowEx (zi, 0, nil nil);
end;
If sun<> 0 then
The begin
PostMessage (fu, WM_SYSCOMMAND, SC_RESTORE, 0);
end;
end;
The SetForegroundWindow (FU);
Sleep (5000);
The GetCursorPos (ps);
SetCursorPos (ps. X, ps. Y);
Sleep (100);

//SendMessage (zi, WM_LBUTTONDBLCLK, 0, 0).
SendMessage (fu, WM_NCACTIVATE, WA_ACTIVE, 0);
SendMessage (fu, WM_LBUTTONDOWN, 0, 0);

SendMessage (fu, WM_LBUTTONUP, 0, 0);
end;

CodePudding user response:

Try BM_CLICK message, it should be the VCL message,

CodePudding user response:

SendMessage (fu, WM_LBUTTONDOWN, 0, 0);
SendMessage (fu, WM_LBUTTONUP, 0, 0);
The two sentences to:
SendMessage (fu, BM_CLICK, 0, 0);

Also I can't, master, thank you very much,

CodePudding user response:

SendMessage (fu, WM_LBUTTONDOWN, 1, and 65535 + x y SHL 16);//x, y is click position coordinates,

CodePudding user response:

SetCursorPos (x, y);
Mouse_event (MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0).
Mouse_event (MOUSEEVENTF_LEFTUP, 0, 0, 0, 0).

CodePudding user response:

I don't have to mouse_event, I need the background, mouse_event is only applicable to the front desk, but still thank you for your reply, thank you very much,

CodePudding user response:

Background button to send the packet, send the packet function go into thread

CodePudding user response:

Make sure you handle properly?

CodePudding user response:

refer to 6th floor elqshhh response:
background button to send the packet, send the packet function into the thread go



The packet will not get, into the thread not yet,

I try to use spy++, capture the mouse click on the message, but the message can capture the mouse movement, is blocking the messages, but if shielding messages, in principle, the mouse message also capture, why is it can capture the mouse message, click on the message can't capture?

CodePudding user response:

refer to 6th floor elqshhh response:
background button to send the packet, send the packet function into the thread go

Packet tried, one packet is kicking off
  • Related