Mirror

Simulate a mouse click on our form (control) (Views: 704)


Problem/Question/Abstract:

Simulate a mouse click on our form (control)

Answer:

This is easily done by position the mouse cursor onto the form using SetCursorPos, then using mouse_event to fake a mouse click.


// click in upper-left corner, 50 pixels inward
  SetCursorPos(Form1.Left + 50, Form1.Top + 50);
  mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
  mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);

<< Back to main page