About Delphi Click on any point in the WebBrowser
Sometimes we need Delphi to load webbrowser1. When you open a webpage, you need to click on a point where the coordinates may be the buttons may be other controls
How should it be implemented? Here's a brief description of the process of clicking on coordinates.
Click the process obviously we move the mouse to click or send a message to click on
Mobile Mouse Click More common here to explain the way to send messages to click
The idea of sending a message to click Is SendMessage () sends a message to implement the
The import handle clicks on it. But here's the handle (WebBrowser's handle) is not really looking for. If you find the right handle, it's still very easy to hit.
Here's a process that clearly explains the SendMessage click Process
Procedure Sendclick (var x,y:integer);
Begin
SendMessage (GetWindow (GetWindow (Form1. Webbrowser1.handle, Gw_child), Gw_child), Wm_lbuttondown,
Mk_lbutton, Makelong (Strtoint (edit2. Text), Strtoint (edit3. Text));
Mk_lbutton, Makelong (x, y));
Sleep (500);
SendMessage (GetWindow (GetWindow (Form1. Webbrowser1.handle, Gw_child), Gw_child), Wm_lbuttonup,
Mk_lbutton, Makelong (Strtoint (edit2. Text), Strtoint (edit3. Text));
Mk_lbutton, Makelong (x, y));
PostMessage (GetWindow (GetWindow (Form1. Webbrowser1.handle, Gw_child), Gw_child), Wm_lbuttondown,
Mk_lbutton, Makelong (Strtoint (edit2. Text), Strtoint (edit3. Text));
Mk_lbutton, Makelong (x, y));
Sleep (500);
PostMessage (GetWindow (GetWindow (Form1. Webbrowser1.handle, Gw_child), Gw_child), Wm_lbuttonup,
Mk_lbutton, Makelong (Strtoint (edit2. Text), Strtoint (edit3. Text));
Mk_lbutton, Makelong (x, y));
End
A process is defined here.
GetWindow (GetWindow (Form1. Webbrowser1.handle, Gw_child), Gw_child) This is WebBrowser's handle.
The whole process sent SendMessage and postmessage2 packages here is to prevent one point at a time so make a point again
The coordinate of the click is the parameter x, y, which is imported in the procedure.
The x y coordinate here is relative to the coordinates of the form, which is relative to the WebBrowser, so you have to use Spy + + to find the coordinates of the click.
About Delphi Click on any point in the WebBrowser