Code Snippet: Move Cursor to Center of Main Screen

2013-10-25 6:46 PM

Having a lot of monitors at work, I sometimes have a hard time finding where the mouse's cursor is on the screen immediately. Here's a helpful little snippet to immediately move the cursor to the center of the primary screen:

Cursor.Position = new Point
        Screen.PrimaryScreen.Bounds.Left +
            ((Screen.PrimaryScreen.Bounds.Right - Screen.PrimaryScreen.Bounds.Left) / 2),
        Screen.PrimaryScreen.Bounds.Bottom + 
            ((Screen.PrimaryScreen.Bounds.Top - Screen.PrimaryScreen.Bounds.Bottom) / 2)