private void StopMonitoring_Click(object sender, EventArgs e) { StartVMMonitor.Enabled = true; MonitorUIObject.Enabled = true; LogTextBox.ResetText(); //remove event handlers uiNodeEvents.OnUiMouse -= uiNodeMonitor_OnUiMouseEvent; uiNodeEvents.OnUiKeyboard -= uiNodeMonitor_OnUiKeyboardEvent; uiSystemEvents.OnUiMouse -= UiSystemEvents_OnUiMouseEvent; uiSystemEvents.OnUiKeyboard -= UiSystemEvents_OnUiKeyboardEvent; //Detach all events uiNodeEvents.StopMonitoring(); uiSystemEvents.StopMonitoring(); }