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);
}