0

I tried this but I think it's for 32bit Windows only.

How to move mouse cursor using C#?

I am getting lots of red underline errors like "Cursor does not contain a definition for Position" and "Rectangle does not contain a constructor that takes 2 arguments"

private void MoveCursor()
{
   // Set the Current cursor, move the cursor's Position,
   // and set its clipping rectangle to the form. 

   this.Cursor = new Cursor(Cursor.Current.Handle);
   Cursor.Position = new Point(Cursor.Position.X - 50, Cursor.Position.Y - 50);
   Cursor.Clip = new Rectangle(this.Location, this.Size);
}

Searched older threads but I think the code is outdated and doesn't work in Windows 64 bit OS. So I'm looking for new code if there is any.

NoobCoder
  • 189
  • 1
  • 10
  • Please include the namespace USINGs aswell. It's hard to decipher this way. – Kristóf Tóth Mar 08 '19 at 10:39
  • there are no special usings – NoobCoder Mar 08 '19 at 10:54
  • Thats okay, but how would we know what rectangle class are you using? What kind of cursor etc. I assume its from System.Drawing but it's not obvious – Kristóf Tóth Mar 08 '19 at 10:58
  • I just copy pasted the code for what I'm trying to do. That is move the desktop mouse cursor to a specific location on screen. I don't know which rectangle class it is referring to. The cursor I'm talking about is the mouse that you move on your desktop to click on stuff. To me, it's also not obvious because no specific using was described in the older threads. – NoobCoder Mar 08 '19 at 11:02
  • If you hover your mouse on a classname it will display the fully qualified name with namespace etc. But lets skip ahead, forget what I asked. What kind of application is this? WPF? WinForms? – Kristóf Tóth Mar 08 '19 at 11:12
  • I hovered. It says Rectangle.Rectangle(). This is WPF. – NoobCoder Mar 08 '19 at 11:16

0 Answers0