4
votes

I'm trying to get the position of the cursor from a multi-monitor display. Using

Point cursorPosition = Cursor.Position;

Returns the cursor's position relative to the monitor it is currently on. If I had two monitors, and I used the above lines of code, and my mouse was on my second monitor (Which is to the right of my first monitor), and I drew the cursor to an image, it would appear on the left hand side monitor, where as it should be on the right hand side monitor.

EDIT:

I'm taking a screenshot of all my monitors and would like to add the cursor to the Bitmap, however using Cursor.Position will put the cursor on the "left hand side" monitor of the screenshot Bitmap even if the cursor was on the "right hand side" monitor.

Thanks

1
How are you drawing? All monitors share a single coordinate space.SLaks
You could get the resolution of every monitor and normalize the mouse position to the total screen resolution?Shawnic Hedgehog
@SLaks the Cursor.Position is always relative to the current display, not the desktop/screen. It resets back to 0/0 on transition to a new display.Ron Beyer
@RonBeyer: I tried it, and that is not true.SLaks
@SLaks you are right, I'm sorry I was thinking of something else, I retract my statement.Ron Beyer

1 Answers

4
votes

You can get screen where cursor is:

var screen = Screen.FromPoint(Cursor.Position);

Take screen into account before you display your image