There are other ways to simulate mouse input. To programmatically click the right mouse buttonĬreate a MouseEventArgs whose Button property is set to the MouseButtons.Right value.Ĭall the OnMouseClick method with this MouseEventArgs as the argument.įor more information on custom controls, see Developing Windows Forms Controls at Design Time. For example, the following steps illustrate how to simulate clicking the right mouse button in code. This option is usually possible only within custom controls and forms, because the methods that raise events are protected and cannot be accessed outside the control or form.
The best way to simulate mouse events is to call the On EventName method that raises the mouse event you want to simulate. This topic provides an overview of these options.
Windows Forms provides several options for programmatically simulating mouse and keyboard input.