Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting mouse position without System.Windows.Forms

Tags:

c#

windows

mouse

Is there a way to manipulate the mouse position without using System.Windows.Forms.Cursor? Something like interop maybe?

Reason for this is that we are using a specialized .NET subset which can't include System.Windows.Forms.

like image 435
Amir Abiri Avatar asked Jun 19 '12 00:06

Amir Abiri


People also ask

How do I change cursor position?

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.

How do you get the mouse position in unity?

In Unity, getting the mouse position on the screen is fairly straightforward. It's a property of the Input class so, to access it from a script, all you need to do is use Input. mousePosition, which returns the position of the mouse, in pixels, from the bottom left of the screen. Simple.

How do I find the cursor position on my screen?

In Mouse Properties, on the Pointer Options tab, at the bottom, select Show location of pointer when I press the CTRL key, and then select OK. To see it in action, press CTRL.


1 Answers

oops my bad, read question too fast, heres the correct PInvoke call

[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);

Source: http://www.pinvoke.net/default.aspx/user32.setcursorpos

like image 174
Jf Beaulac Avatar answered Oct 05 '22 23:10

Jf Beaulac