Domanda

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?

È stato utile?

Soluzione

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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top