0

Here is a brief background of the project and what I have done so far:

I am working on a program in which all the actions performed in a form are replayed. What I have done so far is captured cursor positions and clicks and saved them in a database (requirement of the project). Now when I replay it, it tells through message box that mouse left click or right click. I have multiple forms ( parent and child, using mdi, they are linked).

my problem:

when I replay, I want all the events to perform again. If some button is clicked and another form is opened, I want it to happen again. and program should tell on which form we are currently on.

My program shows the mouse movement and clicks but does not perform the action (e.g. if while recording I pressed a button, and replay it later, it tells mouse left click, but does not actually click the button)

public void display_one(int i)
{
    Cursor.Position = new System.Drawing.Point(temporary[i].mousePositionX, temporary[i].mousePositonY);
    if (temporary[i].mouseRightClick)
    {
        MessageBox.Show("Right Click");
        MouseRightClick();
    }
    if (temporary[i].mouseLeftClick)
    {
        MessageBox.Show("Left Click");
        MouseLeftClick();
    }
}

public void MouseLeftClick()
{
    mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
    Thread.Sleep(50);
    mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}

public void MouseRightClick()
{
    mouse_event(MOUSEEVENTF_RIGHTDOWN , 0, 0, 0, 0);
    Thread.Sleep(50);
    mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
}
Dan Homola
  • 3,819
  • 1
  • 28
  • 43
  • What is not working? What have you tried so far? Show us some code. – Jordy Langen Jul 24 '13 at 06:41
  • here is what i did for mouse click event generation but it is not working mouse position public void display_one(int i) { Cursor.Position = new System.Drawing.Point(temporary[i].mousePositionX, temporary[i].mousePositonY); if (temporary[i].mouseRightClick) { MessageBox.Show("Right double Click"); MouseRightClick(); } if (temporary[i].mouseLeftClick) { MessageBox.Show("Left double Click"); MouseLeftClick(); } } – user2499958 Jul 24 '13 at 06:59
  • for mouse left click : public void MouseLeftClick() { mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); Thread.Sleep(50); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } – user2499958 Jul 24 '13 at 06:59
  • i took help form this link http://stackoverflow.com/questions/8272681/how-can-i-simulate-a-mouse-click-at-a-certain-position-on-the-screen but it is not working – user2499958 Jul 24 '13 at 07:00
  • 2
    When people ask for code, please *edit* your question (link at bottom left), insert the code, and use the `{}` code samples button, so that it's *readable*. Code in comments isn't. – Damien_The_Unbeliever Jul 24 '13 at 07:02

0 Answers0