public override void Start() { foreach (RawDevice device in RawDevice.GetRawDevices()) { if (device.RawType == RawType.Mouse) { deviceList.Add(device.Handle, new CursorData()); } } Thread t = new Thread((ThreadStart) delegate { RawDevice.RegisterRawDevices(0x01, 0x02, InputMode.BackgroundMode | InputMode.SuppressMessages); RawDevice.RawInput += RawDevice_RawInput; lowLevelMouseHook = new LowLevelMouseHook(MouseHookCallback); System.Windows.Forms.Application.Run(); }); t.IsBackground = true; t.SetApartmentState(ApartmentState.STA); t.Start(); timer = new Timer(10); timer.Elapsed += timer_Elapsed; timer.Start(); Mouse.OverrideCursor = Cursors.None; isRunning = true; }
void InputWorker() { RawDevice.RegisterRawDevices(0x01, 0x02, InputMode.BackgroundMode); RawDevice.RegisterRawDevices(HID_USAGE_PAGE_DIGITIZER, HID_USAGE_DIGITIZER_PEN, InputMode.BackgroundMode); RawDevice.RawInput += RawDevice_RawInput; hook = new LowLevelMouseHook(OnMouseAction); Application.Run(); }