Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
SendMouseEvent
Re: SendMouseEvent
I modified the WindowlessBrowser demo, attached.
You do not have the required permissions to view the files attached to this post.
- salvadordf
- Posts: 4620
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: SendMouseEvent
I just uploaded a new WindowlessBrowser demo for VCL that includes a context menu option to execute custom JavaScript.
The browser loads this forum and the default JS code sends the coordinates of the search box in JSON format.
WVBrowser1WebMessageReceived parses the JSON to get the coordinates and simulates a left mouse click on the middle of the element and you will see the blinking caret on it.
The browser loads this forum and the default JS code sends the coordinates of the search box in JSON format.
WVBrowser1WebMessageReceived parses the JSON to get the coordinates and simulates a left mouse click on the middle of the element and you will see the blinking caret on it.
Re: SendMouseEvent
Thank you, Salvador, unfortunately the getBoundingClientRect() returns floating point values but the JSON parser expects integers.
- salvadordf
- Posts: 4620
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: SendMouseEvent
Thanks for reporting that issue!
I just uploaded the fix.
I just uploaded the fix.
Re: SendMouseEvent
Okay, now this works the same as the way my version was doing, which is to shift the point left and up from the target. I'm using Windows 11 on a laptop. Could this behavior be caused by my setup somehow?
Edit: I just discovered that my display is scaled to 150%. If I change it to 100%, then the simulated mouse click works. The problem with this is that with 100% scaling everything on the screen is smaller.
Edit 2: So now what I do is multiply the values from getBoundingClientRect() by WVBrowser1.ScreenScale and it works perfectly!
Edit: I just discovered that my display is scaled to 150%. If I change it to 100%, then the simulated mouse click works. The problem with this is that with 100% scaling everything on the screen is smaller.
Edit 2: So now what I do is multiply the values from getBoundingClientRect() by WVBrowser1.ScreenScale and it works perfectly!
- salvadordf
- Posts: 4620
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: SendMouseEvent
Fixed. Thanks!