It is very easy to get the position of cursor out side the form's boundary by just dragaging the mouse it sends many values to the form when ever the position changes, form the following line of code.
MessageBox.Show(Cursor.Position.ToString());
But I need to get the mouse position when user clicked out side the forms boundary.
Not by just hovering the mouse. I used the following line of Code to do this:
private void Form1_Deactivate(object sender, EventArgs e)
{
MessageBox.Show(Cursor.Position.ToString());
}
I placed MessageBox.Show(Cursor.Position.ToString()); into forms Deactivate event. When user click outside the form this event definitely occures. But it also sends wrong values when user does not click outside but changes the program by using ALT + TAB key combination.
Actually I have to capture screen shot of the area starting from the position of first click. Therefore I need the position of the cursor when it is clicked outside the form.
like:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…