Problem with virtual mouse click
- by Alex
Hi.
I have a program that simulates mouse click.
Code is something like this:
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
public static void DoMouseClick(int x, int y)
{
Cursor.Position = new Point(x, y);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, x, y, 0, 0);
}
This code works perfectly. For example I call this function every 30 minutes. But if I press WINKEY+L (Windows is locked) only cursor is moved but not press occurs.
Any ideas?