I have a program that simulates mouse click.
Code is something like this:
[DllImport("user32.dll", CharS开发者_如何学Pythonet = 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?
The Login screen on windows is designed to NOT allow clicks and automation of UI, as a security feature, IIRC
精彩评论