public void Start() { try { lowLevelKeyboardListener = new LowLevelKeyboardListener(); lowLevelKeyboardListener.OnKeyPressed += LowLevelKeyboardListener_OnKeyPressed; lowLevelKeyboardListener.HookKeyboard(); } catch (Exception ex) { LogHelper.LogException(ex); Stop(); } }
public void Stop() { try { //unsubscribe if (lowLevelKeyboardListener != null) { lowLevelKeyboardListener.OnKeyPressed -= LowLevelKeyboardListener_OnKeyPressed; lowLevelKeyboardListener.UnHookKeyboard(); lowLevelKeyboardListener = null; } } catch (Exception ex) { LogHelper.LogException(ex); } }