CEF Simulate Mousedown and Keysend

Ludger picture Ludger · Jun 30, 2015 · Viewed 10.1k times · Source

I want to use CEF to control a Flash Application, so I need to simulate MouseDown and KeySend without JavaScript. I am using offscreen rendering. This is what I tried:

managedCefBrowserAdapter.OnMouseButton(
    500, 500, 0, true, 2, CefEventFlags.LeftMouseButton); 

or

MouseEvent a = new MouseEvent();
a.Modifiers = CefEventFlags.LeftMouseButton;
a.X = 500;
a.Y = 500;

or

managedCefBrowserAdapter.SendKeyEvent(0, 0, 0);

But nothing works.

Answer

Technostar picture Technostar · Jan 21, 2016

This code works for me. Clicks once on the position 0, 0 (left-upper corner)

browser.GetBrowser().GetHost().SendMouseClickEvent(0, 0, MouseButtonType.Left, false, 1, CefEventFlags.None);
System.Threading.Thread.Sleep(100);
browser.GetBrowser().GetHost().SendMouseClickEvent(0, 0, MouseButtonType.Left, true, 1, CefEventFlags.None);