DotNetBrowser provides an ability to simulate mouse move, wheel, and click events. Simulation is available in the both lightweight and heavyweight mode for WPF and Windows Forms.


Mouse move simulation example


To simulate mouse move you should call an appropriate method with coordinates you want to set a virtual mouse cursor.


var browser = BrowserFactory.Create(BrowserType.LIGHTWEIGHT); //Also you can use BrowserType.HEAVYWEIGHT
var browserView = new WPFBrowserView(browser); //Also you can use WinFormsBrowserView

var x = 887;
var y = 47;

browserView.InputSimulator.SimulateMouseMoveEvent(x, y);


Mouse click simulation example


The mouse click is a sequence of mouse down and mouse up events. To simulate mouse button click you should specify coordinates you want to set a virtual mouse cursor and the button you want to click.


var x = 887;
var y = 47;
var clickCount = 1;

browserView.InputSimulator.SimulateMouseButtonEvent(MouseButton.Left, MouseButtonState.Pressed, clickCount, x, y);
browserView.InputSimulator.SimulateMouseButtonEvent(MouseButton.Left, MouseButtonState.Released, clickCount, x, y);


Mouse wheel simulation example


To simulate mouse wheel event you should specify the direction of the wheel rotation. In addition, you should specify the virtual mouse cursor position. To use horizontal scroll you should set an appropriate parameter as "True":


var x = 887;
var y = 47;
var directionAndCount = -5; //Positive value will scroll up, negative will scroll down
var isHorizontalScroll = false;

browserView.InputSimulator.SimulateMouseWheelEvent(x, y, directionAndCount, isHorizontalScroll);