How can you implement a smooth movement of the mouse cursor to a point on the C # screen in Microsoft Visual Studio?

  • In the sense of "smooth"? "Point" - is it breakpoint or any place? Usually, to navigate through the previous, current position, use the ctrl и + and ctrl и - keys (or the back and forth mouse buttons). Between breakpoints, as far as I know, it’s impossible to cross over with shokatas (except F10, F11, SHift + F11) - GRUNGER
  • Do you mean a mouse cursor or a text cursor? - VladD
  • one
    I mean the mouse cursor. My program clicks on the buttons on the site, but the cursor instantly moves, and I want it to be smooth so that the person does it. - J.Do
  • @ J.Do: If the program clicks on the buttons, do you use some kind of framework for this? - VladD
  • GRUNGER, I do not understand what you mean, but I think that any place on the screen. And I think that this is not that) - J.Do

1 answer 1

Smooth movement can be implemented on a timer.

For example, in a Windows Forms application. Or in an application of any other type, but you also need to add a link to the System.Windows.Forms.dll library in the References project. This is needed so that you can access the Position property of the Cursor class.

In the code we write:

 using System.Windows.Forms; // Поле класса System.Threading.Timer timer; // Создаём и запускаем таймер с интервалом 10 миллисекунд timer = new System.Threading.Timer(CursorMove, null, 0, 10); // Метод, вызываемый таймером. Перемещает курсор private void CursorMove(object state) { var point = Cursor.Position; point.X++; Cursor.Position = point; } 

When the timer needs to be stopped, we call

 timer.Dispose();