问题
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?
回答1:
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);
来源:https://stackoverflow.com/questions/18725003/mouse-position-on-extended-displays