开发者

Problem with virtual mouse click

开发者 https://www.devze.com 2022-12-23 14:57 出处:网络
I have a program that simulates mouse click. Code is something like this: [DllImport(\"user32.dll\", CharS开发者_如何学Pythonet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]

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

0

精彩评论

暂无评论...
验证码 换一张
取 消