Page 1 of 1

Sending mouse events

Posted: Sat May 30, 2020 5:21 am
by dian
I'm trying to send click to youtube video to start playing

1 Tried SendMouseClickEvent:

Code: Select all

    TempEvent.x         := X;
    TempEvent.y         := Y;
    TempEvent.modifiers := EVENTFLAG_IS_LEFT;

    DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
    Chromium.SendMouseClickEvent(@TempEvent, MBT_LEFT, False, 1);
but this didn't work

2 Tried SendMessage() to CEFWindowParent.Handle - this also didn't work

3 Tried to emulate clicks via js - this sometimes worked.
Sometimes didn't. Rather strange. No errors were reported.

Which is the reliable way to send clicks? Or do I need something more to make playing?

Re: Sending mouse events

Posted: Sat May 30, 2020 7:20 am
by salvadordf
Hi,

Try changing the autoplay policy in your application with this :

Code: Select all

GlobalCEFApp.AutoplayPolicy := appNoUserGestureRequired;
If you control the web page contents then add an "autoplay" parameter to the YouTube link like this :
https://stackoverflow.com/questions/340 ... or-youtube

The SimpleOSRBrowser demo calls TChromium.SendMouseClickEvent for the OnMouseUp and OnMouseDown events. Perhaps you need to emulate both events.

Re: Sending mouse events

Posted: Mon Jun 01, 2020 2:11 am
by dian
Setting AutoplayPolicyappeared to be enough. Js version of clicks now also seems to work always

Thank you very much!