Click to See Complete Forum and Search --> : need code for c# to give mouse position when left mouse button...


need2no
September 18th, 2009, 06:36 PM
need code for c# to give mouse position when left mouse button is clicked ...

Can some one help me in c# .. in my app, I want to have app return to me the SCREEN (nor Form) coordinates of mouse pointer when the left mouse button is clicked ....

I know this can be done, but I can't quite write the code to do it properly .... if anyone could help me, that would just be great.

Thank you.

BigEd781
September 18th, 2009, 09:14 PM
Cursor.Position

need2no
September 18th, 2009, 09:37 PM
But how do I 'watch for & detect' the 'left mouse click' ?

BigEd781
September 18th, 2009, 09:40 PM
You want to detect a mouse click at any time? That would require a hook into the OS. If you want to be notified when your form is clicked simply handle OnMouseClick or OnMouseDown.

Here is an article on how to set a hook using C#:

http://support.microsoft.com/kb/318804

need2no
September 18th, 2009, 10:10 PM
I will check it out ... thanks so much :)