jasonpang / Interceptor

C# wrapper for a Windows keyboard driver. Can simulate keystrokes and mouse clicks in protected areas like the Windows logon screen (and yes, even in games). Wrapping http://oblita.com/Interception
MIT License
286 stars 84 forks source link

How to solve mouse freeze / windows freeze / you can not click on any after playing around with interceptor? #19

Closed hoanglong241231 closed 4 years ago

hoanglong241231 commented 4 years ago

If you tried to use input.MouseFilterMode = MouseFilterMode.All; And everything worked but after that you could not use your mouse to click on anything? The problem is caused by "Thread.Sleep". If you are the one who use "await Task.Delay" instead to make a delay and never use the "Thread.Sleep", since the Thread.Sleep(x) will freeze your GUI for x millisecond, well, this is the solution for you. Here is the things you can try: Solution 1: Remove the Thread.Sleep in SendLeftClick() and SendRightClick() function - for those who didn't use the Thread.Sleep:

        public void SendLeftClick()
        {
            SendMouseEvent(MouseState.LeftDown);
            //Thread.Sleep(ClickDelay);
            SendMouseEvent(MouseState.LeftUp);
        }

        public void SendRightClick()
        {
            SendMouseEvent(MouseState.RightDown);
            //Thread.Sleep(ClickDelay);
            SendMouseEvent(MouseState.RightUp);
        }

Solution 2: Add "using System.Threading;" in your main code.

hoanglong241231 commented 4 years ago

:| Easier If you are using both keyboard and mice function of interceptor, then, just use 2 seperate Input for them:

Input input_mouse = new Input();
Input input_keyboard = new Input();

and do stuff separate like:

input_mouse.SendRightClick();
input_keyboard.SendKeys(Interceptor.Keys.A);

Also you may want to Load and Unload both:

input_mouse.Load();
input_keyboard.Load();
////
input_mouse.Unload();
input_keyboard.Unload();