I want to move mouse and click on control in run time. But between form initialize and show form to user was delay about 1 second and this cause mouse clicked on the parent form of this form.
I use Show
method, Load
method but not fix my problem. i don't use timer.
How can i fix this? thanks.
my code to click on control is here:
private const UInt32 MOUSEEVENTF_LEFTDOWN = 0x0002;
private const UInt32 MOUSEEVENTF_LEFTUP = 0x0004;
[DllImport("user32.dll")]
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, uint dwExtraInf);
int x = Convert.ToInt16(trvPointTitls.Location.X+trvPointTitls.Width-10);
int y = Convert.ToInt16(trvPointTitls.Location.Y-10);
Cursor.Position = new Point(x, y);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);