question

nachoshaw-9496 avatar image
0 Votes"
nachoshaw-9496 asked XingyuZhao-MSFT answered

Mouse click listener

Hi

Not even sure if this is possible. I use a design application with a design interface. I need to place points where ever I make a mouse down click but the application doesn't provide a way of doing that. Well, it does but not while a built in process is in operation.

What I would like to do is-
Start a built in tool in the application
Have a mouselistener to record mouse down chords

What I can do with the app is get its top left of the app and also top left of the design window along with its width and height so I could calculate the click point in the window.

Is there a way to do what I'm thinking that is, record the mousedown event and record its coords?


Thanks

dotnet-standard
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

XingyuZhao-MSFT avatar image
0 Votes"
XingyuZhao-MSFT answered

Hi @nachoshaw-9496 ,
In winform, you can use 'Cursor.Position.X' and 'Cursor.Position.Y' to get the cursor position.
Then bind to bind to MouseDown event.

         private void Form1_MouseDown(object sender, MouseEventArgs e)
         {
             label1.Text = "X:" + Cursor.Position.X; 
             label2.Text = "Y:" + Cursor.Position.Y; 
         }

Also take a look at:
Getting mouse position in c#

Hope them could be helpful.

Best Regards,
Xingyu Zhao


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.