سؤال

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?

هل كانت مفيدة؟

المحلول

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);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top