1

I want to get mouse click events on Windows form (just right click) and send them to the server so when it will read them, it will preform mouse clicks.
I couldn't find event that indicates right mouse click.
From all the information online I didn't understand all the 0*02 things and how it relates to simulating a mouse click.

How i can indicate if it was a right click or left?

Siguza
  • 21,155
  • 6
  • 52
  • 89
Shay Sandler
  • 111
  • 10
  • possible duplicate of [How to simulate Mouse Click in C#?](http://stackoverflow.com/questions/2416748/how-to-simulate-mouse-click-in-c) – gpullen Jun 27 '15 at 14:50
  • Though an answer has been marked, I'd really like to understand what you're trying to do. You want to send a mouseclick event to the window within the same application ? I would think a simple call to Control.OnMouseClick(mousearg) should be sufficient ? – Luc Morin Jun 27 '15 at 15:39
  • I want to send something from the server to the client even a Boolean which after receiving it it will mouse click in the client computer – Shay Sandler Jun 27 '15 at 18:57
  • What kind of client/server environment are you using ? – Luc Morin Jun 27 '15 at 20:08
  • what do you meen by enviorment? its C# multithreded server on TCP protocol – Shay Sandler Jun 27 '15 at 20:26
  • Yes, that's what I meant. So the client opens a TCP connection to the server, and I assume you keep the connection opened and that both the client and server listen to some messages. Is that correct ? – Luc Morin Jun 27 '15 at 20:42
  • yes it is. you are right – Shay Sandler Jun 27 '15 at 20:48
  • So, why do you want to simulate a "click" event ? Why don't you simply call the code that does whatever action it is you want to do on the client when the server sends the specific message ? It seems to me your UI code is maybe too tightly coupled to your business code. You would benefit having the business code apart from the UI code, and then you would be able to call the business code instead of simulating a UI action. – Luc Morin Jun 27 '15 at 21:37
  • Yeah you are right i will re arrange it thank you for your help! – Shay Sandler Jun 27 '15 at 22:01

1 Answers1

3

There isn't a separate event for right/left/other mouse click. There is only a MouseClick event. But a MouseClick event is a delegate of type MouseEventHandler, a MouseEventHandler receives an argument e of type MouseEventArgs, a MouseEventArgs instance has a property named Button of type MouseButtons enumeration, here you can find what kind of button has been pressed. In the link above a lot of examples how to use these infos.

This should answer your question, but the remainder of your problem (passing this information to a remote server) is totally unclear

Steve
  • 213,761
  • 22
  • 232
  • 286
  • i want to simulate a mouse click from the code somthing like this.click what about the function preform mouth click? – Shay Sandler Jun 27 '15 at 13:57
  • All the information that you can get from the MouseClick event is stored in the e parameter of type MouseEventArgs. You could try to pass this instance to your server application that manages the fake mouse-click on the server (If I have understood you correctly) – Steve Jun 27 '15 at 14:01