Click here to Skip to main content
15,884,066 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have active left and right mouse click for example if k==1 active left mouse click and if k==0 active right mouse click
thank you
Posted
Comments
Maciej Los 21-Aug-13 2:40am    
What?
Please, be more specific and provide more details...
Member 10222088 21-Aug-13 3:04am    
I want to simulate left click and right click the mouse

1 solution

If you are trying to deteect it:
C#
if (Mouse.Buttons == MouseButtons.Left)
    {
    ...
else if (Mouse.Buttons == MouseButtons.Right)
    {
    ...
    }

If you are trying to simulate a mouse button press, then you can use Button.PerformClick[^], but there is no direct way to force a right click in .NET - you would probably have to use PInvoke to send a mouse message to teh relevant control.

A better way would be to extract the code from the Click event handler and call it directly...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900