Inheritance: System.EventArgs
Beispiel #1
0
        private void OnKeyPressed(object sender, KeyPressedEventArgs e)
        {
            if (!IsCapturing)
            {
                return;
            }

            switch (e.State)
            {
                case KeyState.Down:
                    //server.AddPacket(new KeyboardPacket((int)e.Key, true));
                    break;
                case KeyState.Up:
                   //server.AddPacket(new KeyboardPacket((int)e.Key, false));
                    break;
            }
        }
Beispiel #2
0
        private void DriverCallback()
        {
#if OLD_API
            InterceptionDriver.SetFilter(context, InterceptionDriver.IsKeyboard, (Int32)KeyboardFilterMode);
            InterceptionDriver.SetFilter(context, InterceptionDriver.IsMouse, (Int32)MouseFilterMode);
#else
            switch (FilterType)
            {
            case FilterType.Whitelist:
                InterceptionDriver.SetFilter(context, InterceptionDriver.IsKeyboardWhitelist, (Int32)KeyboardFilterMode);
                InterceptionDriver.SetFilter(context, InterceptionDriver.IsMouseWhitelist, (Int32)MouseFilterMode);
                break;

            case FilterType.Blacklist:
                InterceptionDriver.SetFilter(context, InterceptionDriver.IsKeyboardBlacklist, (Int32)KeyboardFilterMode);
                InterceptionDriver.SetFilter(context, InterceptionDriver.IsMouseBlacklist, (Int32)MouseFilterMode);
                break;

            default:
                InterceptionDriver.SetFilter(context, InterceptionDriver.IsKeyboard, (Int32)KeyboardFilterMode);
                InterceptionDriver.SetFilter(context, InterceptionDriver.IsMouse, (Int32)MouseFilterMode);
                break;
            }
#endif
            Stroke stroke = new Stroke();

            while (InterceptionDriver.Receive(context, deviceId = InterceptionDriver.Wait(context), ref stroke, 1) > 0)
            {
                if (InterceptionDriver.IsMouse(deviceId) > 0)
                {
                    if (OnMouseAction != null)
                    {
                        var args = new MousePressedEventArgs(deviceId)
                        {
                            X          = stroke.Mouse.X,
                            Y          = stroke.Mouse.Y,
                            State      = stroke.Mouse.State,
                            Rolling    = stroke.Mouse.Rolling,
                            DeviceId   = deviceId,
                            DeviceName = GetDeviceName(deviceId)
                        };
                        OnMouseAction(this, args);

                        if (args.Handled)
                        {
                            continue;
                        }
                        stroke.Mouse.X       = args.X;
                        stroke.Mouse.Y       = args.Y;
                        stroke.Mouse.State   = args.State;
                        stroke.Mouse.Rolling = args.Rolling;
                    }
                }

                if (InterceptionDriver.IsKeyboard(deviceId) > 0)
                {
                    if (OnKeyPressed != null)
                    {
                        var virtualKey = (VirtualKeys)MapVirtualKey((uint)stroke.Key.Code, 1);

                        if (virtualKey > VirtualKeys.Left && virtualKey < VirtualKeys.Down && !stroke.Key.State.HasFlag(KeyState.E0))
                        {
                            switch (virtualKey)
                            {
                            case VirtualKeys.Left:
                                virtualKey = VirtualKeys.N4;
                                break;

                            case VirtualKeys.Right:
                                virtualKey = VirtualKeys.N6;
                                break;

                            case VirtualKeys.Up:
                                virtualKey = VirtualKeys.N8;
                                break;

                            case VirtualKeys.Down:
                                virtualKey = VirtualKeys.N2;
                                break;
                            }
                        }

                        var args = new KeyPressedEventArgs()
                        {
                            Key        = virtualKey,
                            State      = stroke.Key.State,
                            DeviceId   = deviceId,
                            DeviceName = GetDeviceName(deviceId)
                        };

                        OnKeyPressed(this, args);

                        if (args.Handled)
                        {
                            continue;
                        }
                        stroke.Key.State = args.State;
                    }
                }

                InterceptionDriver.Send(context, deviceId, ref stroke, 1);
            }

            Unload();
            throw new Exception("Interception.Receive() failed for an unknown reason. The driver has been unloaded.");
        }
Beispiel #3
0
        private void DriverCallback()
        {
            InterceptionDriver.SetFilter(context, InterceptionDriver.IsKeyboard, (Int32) KeyboardFilterMode);
            InterceptionDriver.SetFilter(context, InterceptionDriver.IsMouse, (Int32) MouseFilterMode);

            Stroke stroke = new Stroke();

            while (InterceptionDriver.Receive(context, deviceId = InterceptionDriver.Wait(context), ref stroke, 1) > 0)
            {
                if (InterceptionDriver.IsMouse(deviceId) > 0)
                {
                    if (OnMousePressed != null)
                    {
                        var args = new MousePressedEventArgs() { X = stroke.Mouse.X, Y = stroke.Mouse.Y, State = stroke.Mouse.State, Rolling = stroke.Mouse.Rolling };
                        OnMousePressed(this, args);

                        if (args.Handled)
                        {
                            continue;
                        }
                        stroke.Mouse.X = args.X;
                        stroke.Mouse.Y = args.Y;
                        stroke.Mouse.State = args.State;
                        stroke.Mouse.Rolling = args.Rolling;
                    }
                }

                if (InterceptionDriver.IsKeyboard(deviceId) > 0)
                {
                    if (OnKeyPressed != null)
                    {
                        var args = new KeyPressedEventArgs() { Key = stroke.Key.Code, State = stroke.Key.State};
                        OnKeyPressed(this, args);

                        if (args.Handled)
                        {
                            continue;
                        }
                        stroke.Key.Code = args.Key;
                        stroke.Key.State = args.State;
                    }
                }

                InterceptionDriver.Send(context, deviceId, ref stroke, 1);
            }

            Unload();
            throw new Exception("Interception.Receive() failed for an unknown reason. The driver has been unloaded.");
        }
Beispiel #4
0
        private void DriverCallback()
        {
            InterceptionDriver.SetFilter(context, InterceptionDriver.IsKeyboard, (Int32)KeyboardFilterMode);
            InterceptionDriver.SetFilter(context, InterceptionDriver.IsMouse, (Int32)MouseFilterMode);

            Stroke stroke = new Stroke();

            int deviceId = -1;

            while (InterceptionDriver.Receive(context, deviceId = InterceptionDriver.Wait(context), ref stroke, 1) > 0)
            {
                if (InterceptionDriver.IsMouse(deviceId) > 0)
                {
                    if (deviceId != mouseDeviceId)
                    {
                        mouseDeviceId = deviceId;
                        this.debug("Mouse device detected. Id updated to " + mouseDeviceId);
                    }

                    if (OnMousePressed != null)
                    {
                        var args = new MousePressedEventArgs()
                        {
                            DeviceId = deviceId, X = stroke.Mouse.X, Y = stroke.Mouse.Y, State = stroke.Mouse.State, Rolling = stroke.Mouse.Rolling
                        };
                        OnMousePressed(this, args);

                        if (args.Handled)
                        {
                            continue;
                        }
                        stroke.Mouse.X       = args.X;
                        stroke.Mouse.Y       = args.Y;
                        stroke.Mouse.State   = args.State;
                        stroke.Mouse.Rolling = args.Rolling;
                    }
                }

                if (InterceptionDriver.IsKeyboard(deviceId) > 0)
                {
                    if (deviceId != keyboardDeviceId)
                    {
                        keyboardDeviceId = deviceId;
                        this.debug("Keyboard device detected. Id updated to " + keyboardDeviceId);
                    }

                    if (OnKeyPressed != null)
                    {
                        var args = new KeyPressedEventArgs()
                        {
                            DeviceId = deviceId, Key = stroke.Key.Code, State = stroke.Key.State
                        };
                        OnKeyPressed(this, args);

                        if (args.Handled)
                        {
                            continue;
                        }
                        stroke.Key.Code  = args.Key;
                        stroke.Key.State = args.State;
                    }
                }

                InterceptionDriver.Send(context, deviceId, ref stroke, 1);
            }

            Unload();
            throw new Exception("Interception.Receive() failed for an unknown reason. The driver has been unloaded.");
        }