Page 2 of 2

Re: SendMouseEvent

Posted: Wed Jun 05, 2024 7:31 pm
by jc4golf
I modified the WindowlessBrowser demo, attached.

Re: SendMouseEvent

Posted: Thu Jun 06, 2024 11:38 am
by salvadordf
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.

Re: SendMouseEvent

Posted: Fri Jun 07, 2024 3:26 am
by jc4golf
Thank you, Salvador, unfortunately the getBoundingClientRect() returns floating point values but the JSON parser expects integers.

Re: SendMouseEvent

Posted: Fri Jun 07, 2024 6:29 am
by salvadordf
Thanks for reporting that issue!
I just uploaded the fix.

Re: SendMouseEvent

Posted: Fri Jun 07, 2024 8:12 pm
by jc4golf
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!

Re: SendMouseEvent

Posted: Sat Jun 08, 2024 7:18 am
by salvadordf
Fixed. Thanks!