About Delphi Click on any point in the WebBrowser

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.