Welcome Guest Search | Active Topics | Sign In | Register

Code example of the simulation of the mouse movement and click(vb.net) Options
Prequena84
Posted: Wednesday, May 26, 2021 10:08:07 AM
Rank: Advanced Member
Groups: Member

Joined: 5/10/2021
Posts: 43
I would like to see an Example of a code for the simulation of the mouse movement and click inside the Webview in a windows form using SendMouseEvent () since the material and the downloadable files there is nothing that refers to this content since the code It is exclusive to the Webview, thanks, for now an example of moving it X, Y and clicking
eo_support
Posted: Wednesday, May 26, 2021 10:28:47 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,206
Hi,

You would need to send a mouse down and a mouse up event. For example, the following code simulate a click at (x, y) location:

Code: C#
webView.SendMouseEvent(
    MouseEventType.Down, 
    new Base.UI.MouseEventArgs(Base.UI.MouseButtons.Left, 1, x, y, 0));
webView.SendMouseEvent(
    MouseEventType.Up, 
    new Base.UI.MouseEventArgs(Base.UI.MouseButtons.Left, 1, x, y, 0));


If you are looking for automating the web page, you may have another option to skip the simulating part completely. A typical browser cycle works this way:

1. The browser loads the page;
2. User enters some data (for example, entering user name and password);
3. User clicks a button to submit the page (for example, clicking "login" button);
4. The browser initiate a request to the server with the data user entered;
5. The server execute the request and send the response back to the browser (for example, login user in and display a welcome page);

What you can do is instead of simulating step 2 and step 3, you can go to step 4 directly using webView.LoadRequest. You would create a Request object and fills the Request objects with data that supposedly be entered by the user, then call WebView.LoadRequest to send the request to the web server directly and you will get the same result for step 5. This is much more reliable and more efficient.

Thanks!

Prequena84
Posted: Wednesday, May 26, 2021 10:38:51 AM
Rank: Advanced Member
Groups: Member

Joined: 5/10/2021
Posts: 43
Great, the position where it is going to move from X and Y, I assign it like this X:= 100, Y:= 50?
eo_support
Posted: Wednesday, May 26, 2021 10:40:33 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,206
Yes. You just replace it with whatever X/Y value you want.
Prequena84
Posted: Wednesday, May 26, 2021 10:43:09 AM
Rank: Advanced Member
Groups: Member

Joined: 5/10/2021
Posts: 43
Great that I am grateful now if I will be able to perform both tests with the webView.LoadRequest and with this way to be able to see the result of the first test this automation thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.