Questions about clicking any point in webbrowser in Delphi

Source: Internet
Author: User
Sometimes we need Delphi to load webbrowser1 to open the webpage. When we need to click a certain point, the coordinates may be the buttons or other controls.
How should we implement it? Here we will briefly describe the process of clicking coordinates.
Obviously, we move the mouse to click or send a message to click.
The following figure shows how to send a message and click it.
The idea of sending a message to click is to send a message by sendmessage ().
Click Import handle. However, the handle here (the webbrowser handle) is hard to find. It is very easy to click a proper handle.
Here is a process that clearly describes the sendmessage click process.
Procedure sendclick (var x, Y: integer );
Begin
Sendmessage (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 (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 (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 (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 (form1.webbrowser1. Handle, gw_child), gw_child) is the webbrowser handle.
The sendmessage and postmessage2 packages are sent throughout the process. This is to prevent the requests from being refreshed once.
The clicked coordinates are the imported parameters X and Y.
Here, the x y coordinate is relative to the form coordinate, which is relative to the webbrowser coordinate. Therefore, you must use Spy ++ to find the clicked coordinate.
 

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.