Frage

I'd like to make a c# app that moves the mouse to a specified x,y position on the screen. I've tried a few codes I found online but none seem to work.

War es hilfreich?

Lösung

Try this:

System.Windows.Forms.Cursor.Position = new Point { X = xxx, Y = yyy };

Or try to use the native WinAPI for XP (or earlier):

[DllImport("user32.dll")]
public static extern long SetCursorPos(int x, int y);

public void SetCursorPosition(Point p)
{
    SetCursorPos(p.X, p.Y);
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top