I've found many articles on how to set the mouse position in a C# windows forms project - I want to do this in a console application. How can I set the absolute mouse position from a C# windows console application?
Thanks!
Hint: it's not Console.setCursorPosition, that only sets the position of the text cursor in the console.
SetCursorPosition(Int32, Int32) Method is used to set the position of cursor. Basically, it specifies where the next write operation will begin in the console window.
You can also use another function SetCursorPos to set the cursor position. The SetCursorPos function can be used in a looping structure to move the cursor across the screen.
1) A cursor is the position indicator on a computer display screen where a user can enter text. In an operating system with a graphical user interface (GUI), the cursor is also a visible and moving pointer that the user controls with a mouse, touch pad, or similar input device.
This is an old thread, but for the sake of completion it can be done this way...
use System.Runtime.InteropServices;
[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);
then in method whatever position you wish e.g.
SetCursorPos(500, 500);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With