MouseMove event: How to force the Cursor to move horizontal smoothly when Shift Key is being pressed in WinForm?

Viewed 22

How to force the Cursor to move horizontally smoothly when Shift Key is being pressed WinForm? I can force the mouse to move horizontally using the 2 very little codes below, however, the Cursor is moving with a lot of flashing.

           int horizontalPosition = 0; //
            mainForm.MouseMove += (s, e) =>
            {
                if (Control.ModifierKeys == Keys.Shift)
                {
                    Cursor.Position = new System.Drawing.Point(Cursor.Position.X, horizontalPosition);
                }

            };

KeyDown to capture the Y position before MouseMove

            mainForm.KeyDown += (s, e) =>
            {
                if (e.KeyCode == Keys.ShiftKey)
                    horizontalPosition = Cursor.Position.Y;
            };
0 Answers
Related