private async void CaptureDevice() { try { cmdAction.Text = "Stop Capture"; IntPtr deviceId = await DeviceManager.DetectKeyboard(); if (deviceId == IntPtr.Zero) { Log(LogType.Test, "Failed to capture device"); } else { scanner = new BatchKeyboard(deviceId); scanner.BatchReceived += Scanner_BatchReceived; StartListen(scanner); Log(LogType.Test, "Captured device ({0})", deviceId); cmdAction.Text = "Release Device"; } } catch (Exception ex) { Log(LogType.Test, "Error capturing device: " + ex.Message); } }
private void ReleaseDevice() { DeviceManager.Listen(null); if (scanner != null) { scanner.BatchReceived -= Scanner_BatchReceived; scanner = null; } if (debugScanner != null) { debugScanner.BatchReceived -= Debug_BatchReceived; debugScanner = null; } ResetButtons(); }
private async void CaptureDevice() { try { cmdAction.Text = "Stop Capture"; IntPtr deviceId = await DeviceManager.DetectKeyboard(); if (deviceId == IntPtr.Zero) Log(LogType.Test, "Failed to capture device"); else { scanner = new BatchKeyboard(deviceId); scanner.BatchReceived += Scanner_BatchReceived; StartListen(scanner); Log(LogType.Test, "Captured device ({0})", deviceId); cmdAction.Text = "Release Device"; } } catch (Exception ex) { Log(LogType.Test, "Error capturing device: " + ex.Message); } }
private void ReleaseDevice() { DeviceManager.Listen(null); if (scanner != null) { scanner.BatchReceived -= Scanner_BatchReceived; scanner = null; } if(debugScanner != null) { debugScanner.BatchReceived -= Debug_BatchReceived; debugScanner = null; } ResetButtons(); }