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

This is not work on Windows 10 #17

Open thienquang07 opened 4 years ago

thienquang07 commented 4 years ago

I had done follow the instruction. My code can build without problems, but it has no effect. Nothing happens, keystroke or mouse click not work on any app: games, chrome or notepad... I did active the target app using SetForegroundWindow() before sending keystroke or mouseclick. Is there anyone could make it work on windows10? Please give me some advice!

calico-crusade commented 4 years ago

I had a similar problem at first, but it ended up being my own mistake. Here are a few things to double check:

If not, please provide code samples for further aid!

thienquang07 commented 4 years ago

Oh yes, after check the Load() method, it returned "false" value. And when I go inside the Load() method, the reason is the InterceptionDriver.CreateContext() return IntPtr.Zero value.

        public bool Load()
        {
            if (IsLoaded) return false;

            context = InterceptionDriver.CreateContext();

            if (context != IntPtr.Zero)
            {
                callbackThread = new Thread(new ThreadStart(DriverCallback));
                callbackThread.Priority = ThreadPriority.Highest;
                callbackThread.IsBackground = true;
                callbackThread.Start();

                IsLoaded = true;

                return true;
            }
            else
            {
                IsLoaded = false;

                return false;
            }
        }

I did put the "interception.dll" file in right place. I really don't know why this happens. Could you show me how to fix that? Thanks in advance!

ErcinDedeoglu commented 3 years ago

Crashed to same problem

keytrap-x86 commented 3 years ago

Same problem over her.

Edit: It works, see this comment. I have successfuly tested this with GTA 5.

First of all, make sure you have installed this driver correctly, see this comment.

Then, you have to press any key on the keyboard so that the program recognizes keyboard's id.

The driver has a limitation in that it can't send keystrokes without receiving at least one keystroke. This is because the driver doesn't know which device id the keyboard is, so it has to wait to receive a keystroke to deduce the device id from your keystroke.

In summary, before sending a keystroke, always physically press the keyboard once. Tap any key. Then you can send keystrokes. This doesn't apply to receiving keystrokes, because by receiving a keystroke, you have of course already pressed a key.

As I only have 1 keyboard, I have changed this line to deviceId = 1; // (my keyboard's id) so that I don't have to press a key first because this value was already set.

To get my keboard's id I added a Console.WriteLine(deviceId); after this line