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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Sending mouse events

Post Reply
dian
Posts: 21
Joined: Thu Aug 29, 2019 8:42 am

Sending mouse events

Post 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?
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Sending mouse events

Post 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.
dian
Posts: 21
Joined: Thu Aug 29, 2019 8:42 am

Re: Sending mouse events

Post by dian »

Setting AutoplayPolicyappeared to be enough. Js version of clicks now also seems to work always

Thank you very much!
Post Reply