Frage

I could not find anything on this particular problem, so here it goes!

I am interested in changing the position of the mouse cursor programmatically.

Cursor.Position = new Point(x, y);

works as expected using a single monitor. However, when I plug in a second one and choose to extend the desktop, changing the cursor's coordinates only works relative to the main screen.

So, does anyone know how to tell the cursor that I want to move to a different screen?

War es hilfreich?

Lösung

Get the width and height of your required screen and move the cursor relative to it

int width=Screen.AllScreens[1].Bounds.Width;
int height=Screen.AllScreens[1].Bounds.Height;
Cursor.Position=new Point(width-x,height-y);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top