[csharp] Simulating mouse movement and events

Status
Not open for further replies.

pyr0

Right off the assembly line
anyone has code that can help me do the following in c# ?

a) move the mouse on the screen, without physically moving the mouse (movement simulation)
b) simulate a left, right or double click at the cursor's current position programatically..

have found the following code on msdn regarding the above.. have got the a) to work.. but no luck with b)

a)
Code:
private void MoveCursor(int a, int b)
        {
            this.Cursor = new Cursor(Cursor.Current.Handle);
            Cursor.Position = new Point(Cursor.Position.X + a, Cursor.Position.Y + b);
            //Cursor.Clip = new Rectangle(this.Location, this.Size);
        }
b)
Code:
To programmatically click the right mouse button

   1. Create a MouseEventArgs whose Button property is set to the System.Windows.Forms.MouseButtons.Right value.
   2. Call the OnMouseClick method with this MouseEventArgs as the argument.

There are other ways to simulate mouse input. For example, you can programmatically set a control property that represents a state that is typically set through mouse input (such as the Checked property of the CheckBox control), or you can directly call the delegate that is attached to the event you want to simulate.

help would me much appreciated

EDIT : am running Microsoft Visual C# 2005 Express Edition, on a pentium4 x86.. windows XP.
 
Status
Not open for further replies.
Top Bottom