Пример #1
0
            public ListeningWindow(KeyDelegate keyHandlerFunction)
            {
                m_KeyHandler = keyHandlerFunction;

                CreateParams createParams = new CreateParams();

                createParams.Caption   = "Hidden window";
                createParams.ClassName = null;
                createParams.X         = 0x7FFFFFFF;
                createParams.Y         = 0x7FFFFFFF;
                createParams.Height    = 0;
                createParams.Width     = 0;
                createParams.Style     = WS_CLIPCHILDREN;

                this.CreateHandle(createParams);

                unsafe
                {
                    RAWINPUTDEV rawInputDevice = new RAWINPUTDEV();
                    rawInputDevice.usUsagePage = 0x01;
                    rawInputDevice.usUsage     = 0x06;
                    rawInputDevice.dwFlags     = RIDEV_INPUTSINK;
                    rawInputDevice.hwndTarget  = this.Handle.ToPointer();

                    RegisterRawInputDevices(&rawInputDevice, 1, (uint)sizeof(RAWINPUTDEV));
                }
            }
Пример #2
0
            /// <summary>
            /// Creating an new listening window instance.
            /// </summary>
            /// <param name="keyHandlerFunction"></param>
            public ListeningWindow(KeyDelegate keyHandlerFunction)
            {
                this.m_KeyHandler = keyHandlerFunction;

                CreateParams cp = new CreateParams();

                // Fill in the CreateParams details.
                cp.Caption   = "Hidden window";
                cp.ClassName = null;
                cp.X         = 0x7FFFFFFF;
                cp.Y         = 0x7FFFFFFF;
                cp.Height    = 0;
                cp.Width     = 0;
                ////cp.Parent = parent.Handle;
                cp.Style = WS_CLIPCHILDREN;

                // Create the actual invisible window
                this.CreateHandle(cp);

                // Register for Keyboard notification
                unsafe
                {
                    try
                    {
                        RAWINPUTDEV myRawDevice = new RAWINPUTDEV();
                        myRawDevice.usUsagePage = 0x01;
                        myRawDevice.usUsage     = 0x06;
                        myRawDevice.dwFlags     = RIDEV_INPUTSINK;
                        myRawDevice.hwndTarget  = this.Handle.ToPointer();

                        if (RegisterRawInputDevices(&myRawDevice, 1, (uint)sizeof(RAWINPUTDEV)) == false)
                        {
                            int err = Marshal.GetLastWin32Error();
                            throw new Win32Exception(err, "ListeningWindow::RegisterRawInputDevices");
                        }
                    }
                    catch
                    {
                        throw;
                    }
                }
            }
Пример #3
0
            public ListeningWindow(KeyDelegate keyHandlerFunction)
            {
                m_KeyHandler = keyHandlerFunction;

                // Think of a stripped down form control.
                // From System.Windows.Forms namespace.
                CreateParams HiddenControls = new CreateParams();

                // Fill in the CreateParams details.
                HiddenControls.Caption   = "Hidden window";
                HiddenControls.ClassName = null;
                HiddenControls.X         = 0x7FFFFFFF;
                HiddenControls.Y         = 0x7FFFFFFF;
                HiddenControls.Height    = 0;
                HiddenControls.Width     = 0;
                HiddenControls.Parent    = Globule.ParentHandle;
                HiddenControls.Style     = WS_CLIPCHILDREN;

                // Create the actual invisible window
                this.CreateHandle(HiddenControls);

                unsafe
                {
                    RAWINPUTDEV myRawDevice = new RAWINPUTDEV();
                    myRawDevice.usUsagePage = 0x01;
                    myRawDevice.usUsage     = 0x06;
                    myRawDevice.dwFlags     = RIDEV_INPUTSINK;
                    myRawDevice.hwndTarget  = this.Handle.ToPointer();

                    // Register the hidden window as a receiever of
                    // input device messages? See MSDN.
                    if (RegisterRawInputDevices(&myRawDevice, 1,
                                                (uint)sizeof(RAWINPUTDEV)) == false)
                    {
                        int err = Marshal.GetLastWin32Error();
                        throw new Win32Exception(err,
                                                 "ListeningWindow::RegisterRawInputDevices");
                    }
                }
            }
 internal static unsafe extern bool RegisterRawInputDevices(RAWINPUTDEV* rawInputDevices, uint numDevices, uint size);
            public ListeningWindow(KeyDelegate keyHandlerFunction)
            {
                m_KeyHandler = keyHandlerFunction;

                CreateParams cp = new CreateParams();

                // Fill in the CreateParams details.
                cp.Caption = "Hidden window";
                cp.ClassName = null;
                cp.X = 0x7FFFFFFF;
                cp.Y = 0x7FFFFFFF;
                cp.Height = 0;
                cp.Width = 0;
                //cp.Parent = parent.Handle;
                cp.Style = WS_CLIPCHILDREN;

                // Create the actual invisible window
                this.CreateHandle(cp);

                // Register for Keyboard notification
                unsafe {
                    try {
                        RAWINPUTDEV myRawDevice = new RAWINPUTDEV();
                        myRawDevice.usUsagePage = 0x01;
                        myRawDevice.usUsage = 0x06;
                        myRawDevice.dwFlags = RIDEV_INPUTSINK;
                        myRawDevice.hwndTarget = this.Handle.ToPointer();

                        if (RegisterRawInputDevices(&myRawDevice, 1, (uint)sizeof(RAWINPUTDEV)) == false) {
                            int err = Marshal.GetLastWin32Error();
                            throw new Win32Exception(err, "ListeningWindow::RegisterRawInputDevices");
                        }
                    }

                    catch { throw; }
                }
            }
Пример #6
0
            public ListeningWindow(KeyDelegate keyHandlerFunction)
            {
                m_KeyHandler = keyHandlerFunction;

                CreateParams createParams = new CreateParams();

                createParams.Caption = "Hidden window";
                createParams.ClassName = null;
                createParams.X = 0x7FFFFFFF;
                createParams.Y = 0x7FFFFFFF;
                createParams.Height = 0;
                createParams.Width = 0;
                createParams.Style = WS_CLIPCHILDREN;

                this.CreateHandle(createParams);

                unsafe
                {
                    RAWINPUTDEV rawInputDevice = new RAWINPUTDEV();
                    rawInputDevice.usUsagePage = 0x01;
                    rawInputDevice.usUsage = 0x06;
                    rawInputDevice.dwFlags = RIDEV_INPUTSINK;
                    rawInputDevice.hwndTarget = this.Handle.ToPointer();

                    RegisterRawInputDevices(&rawInputDevice, 1, (uint)sizeof(RAWINPUTDEV));
                }
            }