Search code examples
c#chromium-embeddedcefsharp

WH_MOUSE_LL to ChromiumWebBrowser (CefSharp)


I'm trying to forward the mouse from global input to a ChromiumWebBrowser object and I'm having some issues. The capture of the mouse is working but forwarding it to the browser object doesn't work. I'm using a class that inherits ChromiumWebBrowser to achive this.

The reason for me wanting to do this is because I'm drawing the form that the browser is on onto the desktop and this causes it not to receive mouse events.

Custom browser class:

public class BGChrome : ChromiumWebBrowser
{
    private UserActivityHook hooker = null;

    public BGChrome(string address, IRequestContext requestContext = null) : base(address, requestContext)
    {
        hooker = new UserActivityHook();
        hooker.OnMouseActivity += new MouseEventHandler(MouseMove);
    }

    private new void MouseMove(object sender, MouseEventArgs e)
    {
        base.OnMouseMove(e);
    }
}

UserActivityHook class: https://hastebin.com/ocuwesogin.cs

Any help is appreciated.


Solution

  • Solved using amaitland's comment. Used http://cefsharp.github.io/api/63.0.0/html/M_CefSharp_WebBrowserExtensions_SendMouseMoveEvent.htm

    To alter my MouseMove function to

    private new void MouseMove(object sender, MouseEventArgs e)
    {
        this.GetBrowserHost().SendMouseMoveEvent(e.X, e.Y, false, new CefEventFlags());
    }