コード例 #1
0
ファイル: Window1.xaml.cs プロジェクト: lkruljac/diplomskiV2
        void StartWndProcHandler()
        {
            IntPtr hwnd  = IntPtr.Zero;
            Window myWin = Application.Current.MainWindow;

            try
            {
                hwnd = new WindowInteropHelper(myWin).Handle;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            //Get the Hwnd source
            HwndSource source = HwndSource.FromHwnd(hwnd);

            //Win32 queue sink
            source.AddHook(new HwndSourceHook(WndProc));

            id = new RawStuff.InputDevice(source.Handle);
            NumberOfKeyboards = id.EnumerateDevices();
            id.KeyPressed    += new RawStuff.InputDevice.DeviceEventHandler(_KeyPressed);
        }
コード例 #2
0
        void initInputDevice()
        {
            System.Windows.Forms.Form mainForm = null;
            foreach (System.Windows.Forms.Form f in System.Windows.Forms.Application.OpenForms)
            {
                if (f.WindowState == System.Windows.Forms.FormWindowState.Maximized)
                {
                    mainForm = f;
                    break;
                }
            }

            if (mainForm == null)
                return;

            IntPtr hwnd = mainForm.Handle;

            inputDevice = new RawStuff.InputDevice(hwnd);
            NumberOfKeyboards = inputDevice.EnumerateDevices();
            inputDevice.KeyPressed += new RawStuff.InputDevice.DeviceEventHandler(_KeyPressed);
        }
コード例 #3
0
        void StartWndProcHandler()
        {
            IntPtr hwnd = IntPtr.Zero;
            Window myWin = System.Windows.Application.Current.MainWindow;

            try
            {
                hwnd = new WindowInteropHelper(myWin).Handle;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            //Get the Hwnd source
            HwndSource source = HwndSource.FromHwnd(hwnd);
            //Win32 queue sink
            source.AddHook(new HwndSourceHook(WndProc));

            id = new RawStuff.InputDevice(source.Handle);
            NumberOfKeyboards = id.EnumerateDevices();

            id.KeyDown += new RawStuff.InputDevice.DeviceEventHandler(onRawKeyDown_callback);
            id.KeyUp += new RawStuff.InputDevice.DeviceEventHandler(onRawKeyUp_callback);
        }