开发者

C# Block mouse movement [duplicate]

开发者 https://www.devze.com 2023-01-22 02:45 出处:网络
This q开发者_JAVA技巧uestion already has answers here: Closed 12 years ago. Possible Duplicates: how to Make the Mouse Freeze c#
This q开发者_JAVA技巧uestion already has answers here: Closed 12 years ago.

Possible Duplicates:

how to Make the Mouse Freeze c#

How can I block keyboard and mouse input in C#?

I'm making a mouse macro program, and I already have the core mostly worked out. It would be nice, though, if I could temporarily block the user from using the mouse while the macro is playing... is this possible in C#?


EDIT

This code works perfectly for me:

    [DllImport("user32.dll")]
    private static extern bool BlockInput(bool block);

    public static void FreezeMouse()
    {
        BlockInput(true);
    }

    public static void ThawMouse()
    {
        BlockInput(false);
    }
0

精彩评论

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