The .NET wrapper class around the C++ library interception.dll.
Пример #1
0
        public void SendMouseEvent(MouseStroke mouseStroke, int device)
        {
            Stroke stroke = new Stroke();

            stroke.Mouse = mouseStroke;
            InterceptionDriver.Send(context, device, ref stroke, 1);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="state"></param>
        public void SendMouseEvent(int x, int y, MouseState state)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();

            mouseStroke.State = state;

            if (state == MouseState.ScrollUp)
            {
                mouseStroke.Rolling = 120;
            }
            else if (state == MouseState.ScrollDown)
            {
                mouseStroke.Rolling = -120;
            }

            stroke.Mouse = mouseStroke;

            Point point = ConvertDevicePoint(x, y);

            stroke.Mouse.X     = point.X;
            stroke.Mouse.Y     = point.Y;
            stroke.Mouse.Flags = MouseFlags.MoveAbsolute;

            InterceptionDriver.Send(context, mouseDeviceId, ref stroke, 1);
        }
Пример #3
0
        private void DriverCallback()
        {
            InterceptionDriver.SetFilter(context, InterceptionDriver.IsKeyboard, (Int32)KeyboardFilterMode);
            InterceptionDriver.SetFilter(context, InterceptionDriver.IsMouse, (Int32)MouseFilterMode);

            Stroke stroke   = new Stroke();
            int    deviceId = 0;

            while (InterceptionDriver.Receive(context, deviceId = InterceptionDriver.Wait(context), ref stroke, 1) > 0)
            {
                if (InterceptionDriver.IsMouse(deviceId) > 0)
                {
                    mouseDeviceId = deviceId;
                    if (OnMousePressed != null)
                    {
                        Log.Debug(TAG, "Mouse Device Detected:[" + deviceId + "] x:" + stroke.Mouse.X + ",y:" + stroke.Mouse.Y + " tag:" + stroke.Mouse.Flags + " state:" + stroke.Mouse.State);
                        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)
                {
                    keyboardDeviceId = deviceId;
                    if (OnKeyPressed != null)
                    {
                        Log.Debug(TAG, "Keyboard Device Detected:[" + deviceId + "]");
                        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.");
        }
Пример #4
0
        /*
         * Attempts to load the driver. You may get an error if the C++ library 'interception.dll' is not in the same folder as the executable and other DLLs. MouseFilterMode and KeyboardFilterMode must be set before Load() is called. Calling Load() twice has no effect if already loaded.
         */
        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);
            }
        }
Пример #5
0
        private void DriverCallback()
        {
            InterceptionDriver.SetFilter(Context, InterceptionDriver.IsKeyboard, (int)KeyboardFilterMode);
            InterceptionDriver.SetFilter(Context, InterceptionDriver.IsMouse, (int)MouseFilterMode);

            Stroke stroke = new Stroke();

            while (InterceptionDriver.Receive(Context, DeviceID = InterceptionDriver.Wait(Context), ref stroke, 1) > 0)
            {
                if (InterceptionDriver.IsMouse(DeviceID) > 0 && OnMousePressed != null)
                {
                    MousePressedEventArgs 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;
                }
                else if (InterceptionDriver.IsKeyboard(DeviceID) > 0 && OnKeyPressed != null)
                {
                    KeyPressedEventArgs 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, args.DeviceID, ref stroke, 1);
                }
                else
                {
                    InterceptionDriver.Send(Context, DeviceID, ref stroke, 1);
                }
            }

            Unload();
            throw new Exception("Interception.Receive() failed for an unknown reason. The driver has been unloaded.");
        }
Пример #6
0
        /*
         * Safely unloads the driver. Calling Unload() twice has no effect.
         */
        public void Unload()
        {
            if (!IsLoaded) return;

            if (context != IntPtr.Zero)
            {
                callbackThread.Abort();
                InterceptionDriver.DestroyContext(context);
                IsLoaded = false;
            }
        }
Пример #7
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to get the current cursor's position, calculates the desired destination's offset, and uses the Win32 API to set the cursor to the new position.
        /// </summary>
        public void MoveMouseBy(int deltaX, int deltaY)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();
            Point       mousecoord  = ConvertDevicePoint(deltaX, deltaY);

            mouseStroke.X = mousecoord.X;
            mouseStroke.Y = mousecoord.Y;

            stroke.Mouse       = mouseStroke;
            stroke.Mouse.Flags = MouseFlags.MoveRelative;

            InterceptionDriver.Send(context, MOUSEID, ref stroke, 1);
        }
Пример #8
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to set the cursor's position and does not use the driver.
        /// Fixed it by using a Convertion!
        /// </summary>
        ///
        public void MoveMouseTo(int x, int y)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();
            Point       mousecoord  = ConvertDevicePoint(x, y);

            mouseStroke.X = mousecoord.X;
            mouseStroke.Y = mousecoord.Y;

            stroke.Mouse       = mouseStroke;
            stroke.Mouse.Flags = MouseFlags.MoveAbsolute;

            InterceptionDriver.Send(context, MOUSEID, ref stroke, 1);
        }
Пример #9
0
        public void SendMouseEvent(MouseState state)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke
            {
                State = state
            };

            mouseStroke.Rolling = (short)(state == MouseState.ScrollUp ? 120 : state == MouseState.ScrollDown ? -120 : mouseStroke.Rolling);

            stroke.Mouse = mouseStroke;

            InterceptionDriver.Send(Context, 12, ref stroke, 1);
        }
Пример #10
0
        public string GetDeviceName(int deviceId)
        {
            if (DeviceLookup.ContainsKey(deviceId))
            {
                return(DeviceLookup[deviceId]);
            }

            var name           = new char[5000];
            var written        = InterceptionDriver.GetHardwareID(context, deviceId, name, name.Length);
            var deviceName     = name.Take(written).Where(e => e != '\0').Select(e => e.ToString()).ToArray();
            var deviceNameFull = deviceName.Length == 0 ? "Unkown" : deviceName.Aggregate((e, f) => e + f);

            DeviceLookup.Add(deviceId, deviceNameFull);
            return(deviceNameFull);
        }
Пример #11
0
        public void SendKey(Keys key, KeyState state)
        {
            Stroke stroke = new Stroke();
            KeyStroke keyStroke = new KeyStroke();

            keyStroke.Code = key;
            keyStroke.State = state;

            stroke.Key = keyStroke;

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

            if (KeyPressDelay > 0)
                Thread.Sleep(KeyPressDelay);
        }
Пример #12
0
        public void SendKey(InterceptionKeys key, KeyState state, int device)
        {
            Stroke    stroke    = new Stroke();
            KeyStroke keyStroke = new KeyStroke
            {
                Code  = key,
                State = state
            };

            stroke.Key = keyStroke;

            InterceptionDriver.Send(Context, device, ref stroke, 1);

            if (KeyPressDelay > 0)
            {
                Thread.Sleep(KeyPressDelay);
            }
        }
Пример #13
0
        public void SendKey(Keys key, KeyState state)
        {
            Stroke    stroke    = new Stroke();
            KeyStroke keyStroke = new KeyStroke();

            keyStroke.Code  = key;
            keyStroke.State = state;

            stroke.Key = keyStroke;

            Console.WriteLine("SendKey Device ID: {0}", deviceId);
            InterceptionDriver.Send(context, deviceId, ref stroke, 1);

            if (KeyPressDelay > 0)
            {
                Thread.Sleep(KeyPressDelay);
            }
        }
Пример #14
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to set the cursor's position and does not use the driver.
        /// </summary>
        public void MoveMouseTo(int x, int y, bool useDriver = false)
        {
            if (useDriver)
            {
                Stroke      stroke      = new Stroke();
                MouseStroke mouseStroke = new MouseStroke();

                mouseStroke.X = x;
                mouseStroke.Y = y;

                stroke.Mouse       = mouseStroke;
                stroke.Mouse.Flags = MouseFlags.MoveAbsolute;

                InterceptionDriver.Send(context, 12, ref stroke, 1);
            }
            {
                Cursor.Position = new Point(x, y);
            }
        }
Пример #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="state"></param>
        public void SendMouseEvent(MouseState state)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();

            mouseStroke.State = state;

            if (state == MouseState.ScrollUp)
            {
                mouseStroke.Rolling = 120;
            }
            else if (state == MouseState.ScrollDown)
            {
                mouseStroke.Rolling = -120;
            }

            stroke.Mouse = mouseStroke;
            InterceptionDriver.Send(context, mouseDeviceId, ref stroke, 1);
        }
Пример #16
0
        public void SendKey(Keys key, KeyState state)
        {
            Stroke    stroke    = new Stroke();
            KeyStroke keyStroke = new KeyStroke();

            keyStroke.Code  = key;
            keyStroke.State = state;

            stroke.Key = keyStroke;

            InterceptionDriver.Send(context, keyboardDeviceId, ref stroke, 1);
            this.debug("Send key " + key.ToString() + " " + state.ToString() + " for device id " + keyboardDeviceId);


            if (KeyPressDelay > 0)
            {
                Thread.Sleep(KeyPressDelay);
            }
        }
Пример #17
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to set the cursor's position and does not use the driver.
        /// </summary>
        public void MoveMouseTo(int x, int y, bool useDriver = false)
        {
            if (useDriver)
            {
                Stroke      stroke      = new Stroke();
                MouseStroke mouseStroke = new MouseStroke();

                mouseStroke.X = x;
                mouseStroke.Y = y;

                stroke.Mouse       = mouseStroke;
                stroke.Mouse.Flags = MouseFlags.MoveAbsolute;

                InterceptionDriver.Send(context, mouseDeviceId, ref stroke, 1);
                this.debug("Move mouse to " + x + ", " + y + " for device id " + mouseDeviceId);
            }
            {
                Cursor.Position = new Point(x, y);
            }
        }
Пример #18
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to get the current cursor's position, calculates the desired destination's offset, and uses the Win32 API to set the cursor to the new position.
        /// </summary>
        public void MoveMouseBy(int deltaX, int deltaY, bool useDriver = false)
        {
            if (useDriver)
            {
                Stroke      stroke      = new Stroke();
                MouseStroke mouseStroke = new MouseStroke();

                mouseStroke.X = deltaX;
                mouseStroke.Y = deltaY;

                stroke.Mouse       = mouseStroke;
                stroke.Mouse.Flags = MouseFlags.MoveRelative;

                InterceptionDriver.Send(context, 12, ref stroke, 1);
            }
            else
            {
                var currentPos = Cursor.Position;
                Cursor.Position = new Point(currentPos.X + deltaX, currentPos.Y - deltaY); // Coordinate system for y: 0 begins at top, and bottom of screen has the largest number
            }
        }
Пример #19
0
        public void SendMouseEvent(MouseState state)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();

            mouseStroke.State = state;

            if (state == MouseState.ScrollUp)
            {
                mouseStroke.Rolling = 120;
            }
            else if (state == MouseState.ScrollDown)
            {
                mouseStroke.Rolling = -120;
            }

            stroke.Mouse = mouseStroke;

            InterceptionDriver.Send(context, mouseDeviceId, ref stroke, 1);
            this.debug("Send mouse state " + state.ToString() + " for device id " + mouseDeviceId);
        }
Пример #20
0
        public void SendMouseEvent(MouseState state, ushort information = 0)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();

            mouseStroke.State       = state;
            mouseStroke.Information = information;

            if (state == MouseState.ScrollUp)
            {
                mouseStroke.Rolling = 120;
            }
            else if (state == MouseState.ScrollDown)
            {
                mouseStroke.Rolling = -120;
            }

            stroke.Mouse = mouseStroke;

            InterceptionDriver.Send(context, 12, ref stroke, 1);
        }
Пример #21
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to set the cursor's position and does not use the driver.
        /// </summary>
        public void MoveMouseTo(int x, int y, bool useDriver = false)
        {
            if (useDriver)
            {
                Stroke      stroke      = new Stroke();
                MouseStroke mouseStroke = new MouseStroke();

                Point point = ConvertDevicePoint(x, y);

                mouseStroke.X     = point.X;
                mouseStroke.Y     = point.Y;
                mouseStroke.State = 0;

                stroke.Mouse       = mouseStroke;
                stroke.Mouse.Flags = MouseFlags.MoveAbsolute;
                InterceptionDriver.Send(context, mouseDeviceId, ref stroke, 1);
            }
            else
            {
                Cursor.Position = new Point(x, y);
            }
        }
Пример #22
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.");
        }
Пример #23
0
        private void DriverCallback()
        {
            InterceptionDriver.SetFilter(context, InterceptionDriver.IsKeyboard, (Int32) KeyboardFilterMode);
            InterceptionDriver.SetFilter(context, InterceptionDriver.IsMouse, (Int32) MouseFilterMode);

            Stroke stroke = new Stroke();
            var isShiftPressed = false;

            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 hardwareIdBuffer = new byte[500];
                        var length = InterceptionDriver.GetHardwareId(context, deviceId, hardwareIdBuffer, 500);
                        var hardwareId = "";

                        var nullCount = 0;
                        for (var i = 0; i < length; i++)
                        {
                            if (hardwareIdBuffer[i] == 0)
                            {
                                nullCount++;
                                continue;
                            }

                            if (nullCount > 2)
                            {
                                hardwareId += "; ";
                            }

                            nullCount = 0;
                            hardwareId += (char)hardwareIdBuffer[i];
                        }

                        //If you need to get capital letters then be sure to have KeyboardFilterMode.All set and only get KeyState.Down codes
                        var isCapsLockOn = Control.IsKeyLocked(System.Windows.Forms.Keys.CapsLock);
                        if (stroke.Key.Code == Keys.LeftShift || stroke.Key.Code == Keys.RightShift)
                            isShiftPressed = stroke.Key.State == KeyState.Down;

                        var asciiKeyCode = (int)KeyEnumToCharacter(stroke.Key.Code, isCapsLockOn, isShiftPressed);

                        var args = new KeyPressedEventArgs()
                        {
                            Key = stroke.Key.Code,
                            State = stroke.Key.State,
                            HardwareId = hardwareId,
                            AsciiKeyCode = asciiKeyCode
                        };

                        OnKeyPressed?.Invoke(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.");
        }
Пример #24
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.");
        }
Пример #25
0
 public void SetMiceDeviceList(int[] deviceIds)
 {
     InterceptionDriver.SetMiceList(deviceIds, deviceIds.Length);
 }