Strange Behaviour for MoveMouseBy
Hello! I seem to be having some issues with the Mouse.MoveMouseBy method. The method seems to move the mouse cursor by about three times the values passed to the deltaX and deltaY parameters. Using a screen ruler and calling:
InputSimulator.Mouse.MoveMouseBy(1300, 0);
meaning 1300 pixels on the positive horizontal axis results in the mouse being moved all the way across the screen which is much more than 1300 pixels. This holds similarly true for the vertical axis:
InputSimulator.Mouse.MoveMouseBy(0, 300);
where the mouse ends up approximately somewhere beyond 900 pixels on the positive vertical axis.
For testing I have used a screen ruler that seems to be correct since I have made it extend all the way across my screen resolution on both horizontal and vertical axes and it fits perfectly, as well as the following simple code:
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsInput;
namespace InputSimulatorPlusTest
{
public partial class Form1 : Form
{
private readonly InputSimulator _inputSimulator;
public Form1()
{
InitializeComponent();
_inputSimulator = new InputSimulator();
}
private async void Form1_OnShown(object sender, EventArgs e)
{
await Task.Delay(10000);
_inputSimulator.Mouse.MoveMouseBy(0, 300);
}
}
}
Is this a known issue, am I missing something and, if it is a bug, could it be fixed? Thanks!
For others passing by, the problem lies with the global mouse pointer acceleration. MoveMouseBy is applied before any mouse acceleration settings get applied such that the pointer will end up farther than what one would expect. You should look into setting a.) a default mouse acceleration and b.) disabling the enhanced pointer precision.