Вопрос

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.

Это было полезно?

Решение

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);
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top